void avformat_free_context(AVFormatContext *s)
{
    int i;
    if (!s)
        return;
    av_opt_free(s);
    if (s->iformat && s->iformat->priv_class && s->priv_data)
        av_opt_free(s->priv_data);
    for (i = 0; i < s->nb_streams; i++)
        free_stream(&s->streams[i]);
    for (i = s->nb_programs - 1; i >= 0; i--) {
        av_dict_free(&s->programs[i]->metadata);
        av_freep(&s->programs[i]->stream_index);
        av_freep(&s->programs[i]);
    }
    av_freep(&s->programs);
    av_freep(&s->priv_data);
    while (s->nb_chapters--) {
        av_dict_free(&s->chapters[s->nb_chapters]->metadata);
        av_free(s->chapters[s->nb_chapters]);
    }
    av_freep(&s->chapters);
    av_dict_free(&s->metadata);
    av_freep(&s->streams);
    av_freep(&s->internal);
    av_free(s);
}
["static void mov_free(AVFormatContext *s)\n{\n    MOVMuxContext *mov = s->priv_data;\n    int i;\n    if (mov->chapter_track) {\n        if (mov->tracks[mov->chapter_track].enc)\n            av_free(mov->tracks[mov->chapter_track].enc->extradata);\n        av_freep(&mov->tracks[mov->chapter_track].enc);\n    }\n    for (i = 0; i < mov->nb_streams; i++) {\n        if (mov->tracks[i].tag == MKTAG('r','t','p',' '))\n            ff_mov_close_hinting(&mov->tracks[i]);\n        av_freep(&mov->tracks[i].cluster);\n        av_freep(&mov->tracks[i].frag_info);\n        if (mov->tracks[i].vos_len)\n            av_free(mov->tracks[i].vos_data);\n    }\n    av_freep(&mov->tracks);\n}", 'void av_freep(void *arg)\n{\n    void *val;\n    memcpy(&val, arg, sizeof(val));\n    memcpy(arg, &(void *){ NULL }, sizeof(val));\n    av_free(val);\n}', 'void ff_mov_close_hinting(MOVTrack *track)\n{\n    AVFormatContext *rtp_ctx = track->rtp_ctx;\n    av_freep(&track->enc);\n    sample_queue_free(&track->sample_queue);\n    if (!rtp_ctx)\n        return;\n    if (rtp_ctx->pb) {\n        av_write_trailer(rtp_ctx);\n        ffio_free_dyn_buf(&rtp_ctx->pb);\n    }\n    avformat_free_context(rtp_ctx);\n}', 'void avformat_free_context(AVFormatContext *s)\n{\n    int i;\n    if (!s)\n        return;\n    av_opt_free(s);\n    if (s->iformat && s->iformat->priv_class && s->priv_data)\n        av_opt_free(s->priv_data);\n    for (i = 0; i < s->nb_streams; i++)\n        free_stream(&s->streams[i]);\n    for (i = s->nb_programs - 1; i >= 0; i--) {\n        av_dict_free(&s->programs[i]->metadata);\n        av_freep(&s->programs[i]->stream_index);\n        av_freep(&s->programs[i]);\n    }\n    av_freep(&s->programs);\n    av_freep(&s->priv_data);\n    while (s->nb_chapters--) {\n        av_dict_free(&s->chapters[s->nb_chapters]->metadata);\n        av_free(s->chapters[s->nb_chapters]);\n    }\n    av_freep(&s->chapters);\n    av_dict_free(&s->metadata);\n    av_freep(&s->streams);\n    av_freep(&s->internal);\n    av_free(s);\n}']