Commit 986de869bd for ffmpeg
commit 986de869bd6ad9992d1a22d7bca3d334c3dc24b9
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Thu Oct 15 18:22:04 2026 +0200
ffplay: keep the list rows and the sort scratch in the allocation of the entries
Assisted-by: Claude
diff --git a/fftools/ffplay_list.c b/fftools/ffplay_list.c
index e2eb063605..00affb1430 100644
--- a/fftools/ffplay_list.c
+++ b/fftools/ffplay_list.c
@@ -758,35 +758,26 @@ void list_view_free(ListView **plv)
ass_library_done(lv->library);
#endif
av_freep(&lv->entries);
- av_freep(&lv->rows);
- av_freep(&lv->sort_tmp);
av_freep(plv);
}
int list_view_show(ListView *lv, const ListEntry *entries, int nb_entries, int selected)
{
ListEntry *copy;
- int *rows, *sort_tmp, previous = list_view_selected(lv);
+ int previous = list_view_selected(lv);
if (!lv->renderer)
return AVERROR(EINVAL);
- copy = av_malloc_array(nb_entries, sizeof(*copy));
- rows = av_malloc_array(nb_entries, sizeof(*rows));
- sort_tmp = av_malloc_array(nb_entries, sizeof(*sort_tmp));
- if (!copy || !rows || !sort_tmp) {
- av_free(copy);
- av_free(rows);
- av_free(sort_tmp);
+ /* the rows and the sort scratch follow the entries */
+ copy = av_malloc_array(nb_entries, sizeof(*copy) + 2 * sizeof(*lv->rows));
+ if (!copy)
return AVERROR(ENOMEM);
- }
if (nb_entries)
memcpy(copy, entries, nb_entries * sizeof(*entries));
av_free(lv->entries);
- av_free(lv->rows);
- av_free(lv->sort_tmp);
lv->entries = copy;
- lv->rows = rows;
- lv->sort_tmp = sort_tmp;
+ lv->rows = (int *)(copy + nb_entries);
+ lv->sort_tmp = lv->rows + nb_entries;
lv->nb_entries = nb_entries;
lv->nb_rows = 0;
lv->has_artist = lv->has_length = 0;