[FFmpeg-devel] [PATCH v2 5/6] libavutil: Add AVMap

Nicolas George george at nsup.org
Tue Apr 15 21:45:27 EEST 2025


Michael Niedermayer (HE12025-04-15):
> +AVMap *av_map_new(AVMapCompareFunc cmp_keyvalue, AVMapCopyFunc copy, AVMapFreeFunc freef)
> +{
> +    AVMap *s = av_mallocz(sizeof(*s));
> +    if (!s)
> +        return NULL;

Please no.

The ability to allocate on stack including room for a few values is more
important than any performance enhancement for large maps.

> +        AVMap *set = av_map_new(our_cmp[settype], NULL, NULL);

… should be :

	AVMap set = av_map_create(cmp, NULL, NULL);

or :

	AVMap set;
	av_map_init(&set, sizeof(set), cmp, NULL, NULL);

Regards,

-- 
  Nicolas George


More information about the ffmpeg-devel mailing list