]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - mp4.c
client: Fix memory leak on exit.
[paraslash.git] / mp4.c
diff --git a/mp4.c b/mp4.c
index 4b8607b185a9a87c845940d86412843654a13c7d..5ca1307f680d366c155b2e98257ba807c5a4fb92 100644 (file)
--- a/mp4.c
+++ b/mp4.c
@@ -240,7 +240,7 @@ static int read_stsz(struct mp4 *f)
                return ret;
        if (t->stsz_sample_size != 0)
                return 1;
-       t->stsz_table = para_malloc(t->stsz_sample_count * sizeof(int32_t));
+       t->stsz_table = arr_alloc(t->stsz_sample_count, sizeof(int32_t));
        for (uint32_t n = 0; n < t->stsz_sample_count; n++) {
                ret = read_int32(f, &t->stsz_table[n]);
                if (ret <= 0)
@@ -260,8 +260,7 @@ static int read_stts(struct mp4 *f)
        ret = read_int32(f, &t->stts_entry_count);
        if (ret <= 0)
                return ret;
-       t->stts_sample_count = para_malloc(t->stts_entry_count
-               * sizeof(int32_t));
+       t->stts_sample_count = arr_alloc(t->stts_entry_count, sizeof(int32_t));
        for (uint32_t n = 0; n < t->stts_entry_count; n++) {
                ret = read_int32(f, &t->stts_sample_count[n]);
                if (ret <= 0)
@@ -284,9 +283,9 @@ static int read_stsc(struct mp4 *f)
        ret = read_int32(f, &t->stsc_entry_count);
        if (ret <= 0)
                return ret;
-       t->stsc_first_chunk = para_malloc(t->stsc_entry_count * sizeof(int32_t));
-       t->stsc_samples_per_chunk = para_malloc(t->stsc_entry_count
-               sizeof (int32_t));
+       t->stsc_first_chunk = arr_alloc(t->stsc_entry_count, sizeof(int32_t));
+       t->stsc_samples_per_chunk = arr_alloc(t->stsc_entry_count,
+               sizeof (int32_t));
        for (uint32_t n = 0; n < t->stsc_entry_count; n++) {
                ret = read_int32(f, &t->stsc_first_chunk[n]);
                if (ret <= 0)
@@ -310,8 +309,7 @@ static int read_stco(struct mp4 *f)
        ret = read_int32(f, &t->stco_entry_count);
        if (ret <= 0)
                return ret;
-       t->stco_chunk_offset = para_malloc(t->stco_entry_count
-               * sizeof(int32_t));
+       t->stco_chunk_offset = arr_alloc(t->stco_entry_count, sizeof(int32_t));
        for (uint32_t n = 0; n < t->stco_entry_count; n++) {
                ret = read_int32(f, &t->stco_chunk_offset[n]);
                if (ret <= 0)
@@ -396,7 +394,7 @@ static int parse_tag(struct mp4 *f, uint8_t parent, int32_t size)
                        goto fail;
                len = subsize - (header_size + 8);
                free(value);
-               value = para_malloc(len + 1);
+               value = alloc(len + 1);
                ret = read_data(f, value, len);
                if (ret <= 0)
                        goto fail;
@@ -609,7 +607,7 @@ static int open_file(const struct mp4_callback *cb, bool meta_only, struct mp4 *
        int ret;
        uint64_t size;
        uint8_t atom_type, header_size;
-       struct mp4 *f = para_calloc(sizeof(*f));
+       struct mp4 *f = zalloc(sizeof(*f));
 
        f->cb = cb;
        while ((ret = atom_read_header(f, &atom_type, &header_size, &size)) > 0) {
@@ -918,7 +916,7 @@ static void *modify_moov(struct mp4 *f, uint32_t *out_size)
                new_ilst_size += TAG_LEN(strlen(f->meta.tags[n].value));
        size_delta = new_ilst_size - (f->ilst_size - 8);
        *out_size = total_size + size_delta;
-       out_buffer = para_malloc(*out_size);
+       out_buffer = alloc(*out_size);
        p_out = out_buffer;
        set_position(f, total_base);
        ret = read_data(f, p_out, f->udta_offset - total_base);
@@ -1046,7 +1044,7 @@ free_moov:
  * function also returns NULL. Otherwise a copy of the tag value is returned
  * and the caller should free this memory when it is no longer needed.
  */
-char *mp4_get_tag_value(const struct mp4 *f, const char *item)
+__malloc char *mp4_get_tag_value(const struct mp4 *f, const char *item)
 {
        for (unsigned n = 0; n < f->meta.count; n++)
                if (!strcasecmp(f->meta.tags[n].item, item))