[vlc-devel] [PATCH] modules: use 16-bit ints for option counts
Lyndon Brown
jnqnfe at gmail.com
Sat Sep 26 23:41:23 CEST 2020
attached. preview:
From: Lyndon Brown <jnqnfe at gmail.com>
Date: Wed, 10 Apr 2019 03:48:17 +0100
Subject: modules: use 16-bit ints for option counts
nothings is going to need more than UINT16_MAX options, let's be sensible
and save the space. note, i may have instead used 8-bit ints, but that's
way too small for the core set.
added an assert on size when adding modules in entry.c to be safe though.
on 64-bit this saves 16 bytes per plugin (of which there are typically
hundreds). i.e. we cut the storage space for this plugin conf data to half
of what it currently is.
diff --git a/src/modules/entry.c b/src/modules/entry.c
index fc7f3cdbb6..cb06085b9c 100644
--- a/src/modules/entry.c
+++ b/src/modules/entry.c
@@ -142,6 +142,8 @@ static module_config_t *vlc_config_create(vlc_plugin_t *plugin, int type)
unsigned confsize = plugin->conf.size;
module_config_t *tab = plugin->conf.items;
+ assert(confsize < UINT16_MAX);
+
if ((confsize & 0xf) == 0)
{
tab = realloc_or_free (tab, (confsize + 17) * sizeof (*tab));
diff --git a/src/modules/modules.h b/src/modules/modules.h
index 93cc1ca289..752b138c84 100644
--- a/src/modules/modules.h
+++ b/src/modules/modules.h
@@ -40,9 +40,9 @@ typedef struct vlc_plugin_t
struct
{
module_config_t *items; /**< Table of configuration items */
- size_t size; /**< Total count of all items */
- size_t count; /**< Count of real options (excludes hints) */
- size_t booleans; /**< Count of options that are of boolean type */
+ uint16_t size; /**< Total count of all items */
+ uint16_t count; /**< Count of real options (excludes hints) */
+ uint16_t booleans; /**< Count of options that are of boolean type */
} conf;
#ifdef HAVE_DYNAMIC_PLUGINS
-------------- next part --------------
A non-text attachment was scrubbed...
Name: confcount.patch
Type: text/x-patch
Size: 1844 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20200926/6805c28c/attachment.bin>
More information about the vlc-devel
mailing list