[vlc-commits] commit: Avoid anonymous compound in add_shortcut (fixes: #3742) ( Rémi Denis-Courmont )
git at videolan.org
git at videolan.org
Sat Jun 19 03:35:56 CEST 2010
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jun 19 04:34:46 2010 +0300| [6b49f68da9e956c0397dab0f4588e33940e84036] | committer: Rémi Denis-Courmont
Avoid anonymous compound in add_shortcut (fixes: #3742)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6b49f68da9e956c0397dab0f4588e33940e84036
---
include/vlc_plugin.h | 11 +++++++----
src/modules/entry.c | 15 +++++++++------
2 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/include/vlc_plugin.h b/include/vlc_plugin.h
index c1a150e..3f51b6e 100644
--- a/include/vlc_plugin.h
+++ b/include/vlc_plugin.h
@@ -120,8 +120,8 @@ enum vlc_module_properties
/**
* Current plugin ABI version
*/
-# define MODULE_SYMBOL 1_2_0b
-# define MODULE_SUFFIX "__1_2_0b"
+# define MODULE_SYMBOL 1_2_0c
+# define MODULE_SUFFIX "__1_2_0c"
/*****************************************************************************
* Add a few defines. You do not want to read this section. Really.
@@ -196,9 +196,12 @@ enum vlc_module_properties
goto error;
#define add_shortcut( ... ) \
+{ \
+ const char *shortcuts[] = { __VA_ARGS__ }; \
if (vlc_module_set (p_submodule, VLC_MODULE_SHORTCUT, \
- sizeof((const char*[]){__VA_ARGS__})/sizeof(const char*), __VA_ARGS__)) \
- goto error;
+ sizeof(shortcuts)/sizeof(shortcuts[0]), shortcuts)) \
+ goto error; \
+}
#define set_shortname( shortname ) \
if (vlc_module_set (p_submodule, VLC_MODULE_SHORTNAME, \
diff --git a/src/modules/entry.c b/src/modules/entry.c
index 2e8b3c2..80f2802 100644
--- a/src/modules/entry.c
+++ b/src/modules/entry.c
@@ -183,14 +183,17 @@ int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
{
unsigned i_shortcuts = va_arg (ap, unsigned);
unsigned index = module->i_shortcuts;
- module->i_shortcuts += i_shortcuts;
-
- module->pp_shortcuts = realloc (module->pp_shortcuts, sizeof( char ** ) * module->i_shortcuts);
- for (; index < module->i_shortcuts; index++)
+ const char *const *tab = va_arg (ap, const char *const *);
+ const char **pp = realloc (module->pp_shortcuts,
+ sizeof (pp[0]) * (index + i_shortcuts));
+ if (unlikely(pp == NULL))
{
- const char *psz_new = va_arg (ap, const char*);
- module->pp_shortcuts[index] = psz_new;
+ ret = -1;
+ break;
}
+ module->pp_shortcuts = pp;
+ module->i_shortcuts = index + i_shortcuts;
+ memcpy (pp + index, tab, sizeof (pp[0]) * i_shortcuts);
break;
}
More information about the vlc-commits
mailing list