[vlc-devel] [PATCH] core: use config count not size
Rémi Denis-Courmont
remi at remlab.net
Mon Sep 28 17:24:36 CEST 2020
Le sunnuntaina 27. syyskuuta 2020, 22.42.57 EEST Lyndon Brown a écrit :
> From: Lyndon Brown <jnqnfe at gmail.com>
> Date: Wed, 17 Apr 2019 18:15:19 +0100
> Subject: core: use config count not size
>
> count already excludes hint items, thus by using that instead of size we
> accurately only allocate the memory required, rather than ending up with
> a chunk of overhead from all of the hint items that don't even get stored
> in it.
>
> as a rough estimate, there are around 1400 hint entry calls in the tree;
> considering most but not all will exist on each platform, this thus avoids
> wasting space for in the region of 1000 unneeded pointers.
>
> diff --git a/src/config/core.c b/src/config/core.c
> index b24ef59ab4..b9ed95da37 100644
> --- a/src/config/core.c
> +++ b/src/config/core.c
> @@ -403,7 +403,7 @@ int config_SortConfig (void)
> size_t nconf = 0;
>
> for (p = vlc_plugins; p != NULL; p = p->next)
> - nconf += p->conf.size;
> + nconf += p->conf.count;
>
> module_config_t **clist = vlc_alloc (nconf, sizeof (*clist));
> if (unlikely(clist == NULL))
OK but IMO this deserves an assertion in the loop that we don't overflow.
--
Rémi Denis-Courmont
http://www.remlab.net/
More information about the vlc-devel
mailing list