[vlc-commits] commit: plugins: allow to set more than one shortcut in on shot. ( Rémi Duraffort )

git at videolan.org git at videolan.org
Thu Jun 10 20:51:58 CEST 2010


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Thu Jun 10 20:19:05 2010 +0200| [ed246608e80f193bf20bbc4bb892c8a19415cfb6] | committer: Rémi Duraffort 

plugins: allow to set more than one shortcut in on shot.

This is faster as we can now alloc the right size for the shortcuts array.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ed246608e80f193bf20bbc4bb892c8a19415cfb6
---

 include/vlc_plugin.h |    4 ++--
 src/modules/entry.c  |   13 ++++++++++---
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/include/vlc_plugin.h b/include/vlc_plugin.h
index eb957ca..6ed7981 100644
--- a/include/vlc_plugin.h
+++ b/include/vlc_plugin.h
@@ -195,9 +195,9 @@ enum vlc_module_properties
     if (vlc_plugin_set (p_module, NULL, VLC_SUBMODULE_CREATE, &p_submodule)) \
         goto error;
 
-#define add_shortcut( shortcut ) \
+#define add_shortcut( ... ) \
     if (vlc_module_set (p_submodule, VLC_MODULE_SHORTCUT, \
-        (const char *)(shortcut))) \
+        sizeof((const char*[]){__VA_ARGS__})/sizeof(const char*), __VA_ARGS__)) \
         goto error;
 
 #define set_shortname( shortname ) \
diff --git a/src/modules/entry.c b/src/modules/entry.c
index e0b48d2..2e8b3c2 100644
--- a/src/modules/entry.c
+++ b/src/modules/entry.c
@@ -181,9 +181,16 @@ int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
 
         case VLC_MODULE_SHORTCUT:
         {
-            const char *psz_new = va_arg (ap, char*);
-            module->pp_shortcuts = realloc (module->pp_shortcuts, sizeof( char ** ) * (module->i_shortcuts + 1));
-            module->pp_shortcuts[module->i_shortcuts++] = psz_new;
+            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 *psz_new = va_arg (ap, const char*);
+                module->pp_shortcuts[index] = psz_new;
+            }
             break;
         }
 



More information about the vlc-commits mailing list