]> git.sesse.net Git - vlc/commitdiff
plugins: allow to set more than one shortcut in on shot.
authorRémi Duraffort <ivoire@videolan.org>
Thu, 10 Jun 2010 18:19:05 +0000 (20:19 +0200)
committerRémi Duraffort <ivoire@videolan.org>
Thu, 10 Jun 2010 18:46:45 +0000 (20:46 +0200)
This is faster as we can now alloc the right size for the shortcuts array.

include/vlc_plugin.h
src/modules/entry.c

index eb957ca1406632d578067fce7633cc0b5cc754f9..6ed798109ea20a354c4714109111e97ee40e08cb 100644 (file)
@@ -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 ) \
index e0b48d293faed0f5915388378fe527537b6f05ac..2e8b3c2977d82b8509d9cea5ebbe97a07636a725 100644 (file)
@@ -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;
         }