Commit c4f6f41c authored by conrad's avatar conrad

Close a memory leak related to using OGGZ_AUTO with theora streams:

	* mark theora auto_metric as internal, ie. its user_data gets
	automatically free'd when the metric is updated.
	* free user_data for internal metrics associated with the whole
	OGGZ object (ie. not just stream-specific metrics) on oggz_close()


git-svn-id: http://svn.annodex.net/liboggz/trunk@585 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent f02dcbfe
......@@ -185,6 +185,9 @@ oggz_close (OGGZ * oggz)
oggz_vector_foreach (oggz->streams, oggz_stream_clear);
oggz_vector_delete (oggz->streams);
if (oggz->metric_internal)
oggz_free (oggz->metric_user_data);
if (oggz->file != NULL) {
if (fclose (oggz->file) == EOF) {
return OGGZ_ERR_SYSTEM;
......
......@@ -47,6 +47,11 @@
#include "oggz_byteorder.h"
#include "oggz_macros.h"
/* Allow use of internal metrics; ie. the user_data for these gets free'd
* when the metric is overwritten, or on close */
int oggz_set_metric_internal (OGGZ * oggz, long serialno, OggzMetric metric,
void * user_data, int internal);
#define INT32_LE_AT(x) _le_32((*(ogg_int32_t *)(x)))
#define INT32_BE_AT(x) _be_32((*(ogg_int32_t *)(x)))
#define INT64_LE_AT(x) _le_64((*(ogg_int64_t *)(x)))
......@@ -173,8 +178,8 @@ auto_theora (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
tdata->keyframe_shift);
#endif
/*oggz_set_metric_internal (oggz, serialno, auto_theora_metric, tdata, 1);*/
oggz_set_metric (oggz, serialno, auto_theora_metric, tdata);
oggz_set_metric_internal (oggz, serialno, auto_theora_metric, tdata, 1);
/*oggz_set_metric (oggz, serialno, auto_theora_metric, tdata);*/
return 1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment