Revision 094d9df7

View differences:

ffmpeg.c
396 396
        if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)
397 397
            url_fclose(s->pb);
398 398
        for(j=0;j<s->nb_streams;j++) {
399
            av_metadata_free(&s->streams[j]->metadata);
399 400
            av_free(s->streams[j]->codec);
400 401
            av_free(s->streams[j]);
401 402
        }
403
        for(j=0;j<s->nb_programs;j++) {
404
            av_metadata_free(&s->programs[j]->metadata);
405
        }
406
        for(j=0;j<s->nb_chapters;j++) {
407
            av_metadata_free(&s->chapters[j]->metadata);
408
        }
409
        av_metadata_free(&s->metadata);
402 410
        av_free(s);
403 411
    }
404 412
    for(i=0;i<nb_input_files;i++)
libavformat/avformat.h
93 93
 */
94 94
int av_metadata_set(AVMetadata **m, AVMetadataTag tag);
95 95

  
96
/**
97
 * Free all the memory allocated for an AVMetadata struct.
98
 */
99
void av_metadata_free(AVMetadata **m);
100

  
96 101

  
97 102
/* packet functions */
98 103

  
libavformat/metadata.c
74 74
    return 0;
75 75
}
76 76

  
77
void av_metadata_free(AVMetadata **pm)
78
{
79
    AVMetadata *m= *pm;
80

  
81
    if(m){
82
        while(m->count--){
83
            av_free(m->elems[m->count].key);
84
            av_free(m->elems[m->count].value);
85
        }
86
        av_free(m->elems);
87
    }
88
    av_freep(pm);
89
}
90

  
77 91
#if LIBAVFORMAT_VERSION_MAJOR < 53
78 92
#define FILL_METADATA(s, key, value) {                                        \
79 93
    if (value && *value &&                                                    \
libavformat/utils.c
2285 2285
        if (st->parser) {
2286 2286
            av_parser_close(st->parser);
2287 2287
        }
2288
        av_metadata_free(&st->metadata);
2288 2289
        av_free(st->index_entries);
2289 2290
        av_free(st->codec->extradata);
2290 2291
        av_free(st->codec);
......
2295 2296
    for(i=s->nb_programs-1; i>=0; i--) {
2296 2297
        av_freep(&s->programs[i]->provider_name);
2297 2298
        av_freep(&s->programs[i]->name);
2299
        av_metadata_free(&s->programs[i]->metadata);
2298 2300
        av_freep(&s->programs[i]->stream_index);
2299 2301
        av_freep(&s->programs[i]);
2300 2302
    }
......
2303 2305
    av_freep(&s->priv_data);
2304 2306
    while(s->nb_chapters--) {
2305 2307
        av_free(s->chapters[s->nb_chapters]->title);
2308
        av_metadata_free(&s->chapters[s->nb_chapters]->metadata);
2306 2309
        av_free(s->chapters[s->nb_chapters]);
2307 2310
    }
2308 2311
    av_freep(&s->chapters);
2309
    if(s->metadata){
2310
        while(s->metadata->count--){
2311
            av_freep(&s->metadata->elems[s->metadata->count].key);
2312
            av_freep(&s->metadata->elems[s->metadata->count].value);
2313
        }
2314
        av_freep(&s->metadata->elems);
2315
    }
2316
    av_freep(&s->metadata);
2312
    av_metadata_free(&s->metadata);
2317 2313
    av_free(s);
2318 2314
}
2319 2315

  

Also available in: Unified diff