static int append_entry(HLSContext *hls, int64_t duration)
{
    ListEntry *en = av_malloc(sizeof(*en));
    if (!en)
        return AVERROR(ENOMEM);
    av_strlcpy(en->name, av_basename(hls->avf->filename), sizeof(en->name));
    en->duration = duration;
    en->next     = NULL;
    if (!hls->list)
        hls->list = en;
    else
        hls->end_list->next = en;
    hls->end_list = en;
    if (hls->nb_entries >= hls->size) {
        en = hls->list;
        hls->list = en->next;
        av_free(en);
    } else
        hls->nb_entries++;
    hls->sequence++;
    return 0;
}
['static int hls_write_trailer(struct AVFormatContext *s)\n{\n    HLSContext *hls = s->priv_data;\n    AVFormatContext *oc = hls->avf;\n    av_write_trailer(oc);\n    ff_format_io_close(s, &oc->pb);\n    avformat_free_context(oc);\n    av_free(hls->basename);\n    append_entry(hls, hls->duration);\n    hls_window(s, 1);\n    free_entries(hls);\n    free_encryption(s);\n    return 0;\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}', 'void av_free(void *ptr)\n{\n#if HAVE_ALIGNED_MALLOC\n    _aligned_free(ptr);\n#else\n    free(ptr);\n#endif\n}', 'static int append_entry(HLSContext *hls, int64_t duration)\n{\n    ListEntry *en = av_malloc(sizeof(*en));\n    if (!en)\n        return AVERROR(ENOMEM);\n    av_strlcpy(en->name, av_basename(hls->avf->filename), sizeof(en->name));\n    en->duration = duration;\n    en->next     = NULL;\n    if (!hls->list)\n        hls->list = en;\n    else\n        hls->end_list->next = en;\n    hls->end_list = en;\n    if (hls->nb_entries >= hls->size) {\n        en = hls->list;\n        hls->list = en->next;\n        av_free(en);\n    } else\n        hls->nb_entries++;\n    hls->sequence++;\n    return 0;\n}']