( b_strict ? strcmp( psz_search, p_parser->psz_object_name )
: !strstr( p_parser->psz_object_name, psz_search ) ) )
{
- char *const *pp_shortcut = p_parser->pp_shortcuts;
- while( *pp_shortcut )
+ char *const *pp_shortcuts = p_parser->pp_shortcuts;
+ int i;
+ for( i = 0; i < p_parser->i_shortcuts; i++ )
{
- if( b_strict ? !strcmp( psz_search, *pp_shortcut )
- : !!strstr( *pp_shortcut, psz_search ) )
+ if( b_strict ? !strcmp( psz_search, pp_shortcuts[i] )
+ : !!strstr( pp_shortcuts[i], psz_search ) )
break;
- pp_shortcut ++;
}
- if( !*pp_shortcut )
+ if( i == p_parser->i_shortcuts )
continue;
}
if( b_verbose )
{
- char *const *pp_shortcut = p_parser->pp_shortcuts;
- while( *pp_shortcut )
+ char *const *pp_shortcuts = p_parser->pp_shortcuts;
+ for( int i = 0; i < p_parser->i_shortcuts; i++ )
{
- if( strcmp( *pp_shortcut, p_parser->psz_object_name ) )
+ if( strcmp( pp_shortcuts[i], p_parser->psz_object_name ) )
{
if( b_color )
utf8_fprintf( stdout, CYAN" s %s\n"GRAY,
- *pp_shortcut );
+ pp_shortcuts[i] );
else
utf8_fprintf( stdout, " s %s\n",
- *pp_shortcut );
+ pp_shortcuts[i] );
}
- pp_shortcut++;
}
if( p_parser->psz_capability )
{
LOAD_STRING( pp_cache[i]->p_module->psz_shortname );
LOAD_STRING( pp_cache[i]->p_module->psz_longname );
LOAD_STRING( pp_cache[i]->p_module->psz_help );
- for( j = 0; j < MODULE_SHORTCUT_MAX; j++ )
+
+ LOAD_IMMEDIATE( pp_cache[i]->p_module->i_shortcuts );
+ if( pp_cache[i]->p_module->i_shortcuts > MODULE_SHORTCUT_MAX )
+ goto error;
+ else if( pp_cache[i]->p_module->i_shortcuts == 0 )
+ pp_cache[i]->p_module->pp_shortcuts = NULL;
+ else
{
- LOAD_STRING( pp_cache[i]->p_module->pp_shortcuts[j] ); // FIX
+ pp_cache[i]->p_module->pp_shortcuts =
+ xmalloc( sizeof( char ** ) * pp_cache[i]->p_module->i_shortcuts );
+ for( j = 0; j < pp_cache[i]->p_module->i_shortcuts; j++ )
+ LOAD_STRING( pp_cache[i]->p_module->pp_shortcuts[j] );
}
+
LOAD_STRING( pp_cache[i]->p_module->psz_capability );
LOAD_IMMEDIATE( pp_cache[i]->p_module->i_score );
LOAD_IMMEDIATE( pp_cache[i]->p_module->b_unloadable );
{
module_t *p_module = vlc_submodule_create( pp_cache[i]->p_module );
free( p_module->psz_object_name );
+ free( p_module->pp_shortcuts );
LOAD_STRING( p_module->psz_object_name );
LOAD_STRING( p_module->psz_shortname );
LOAD_STRING( p_module->psz_longname );
LOAD_STRING( p_module->psz_help );
- for( j = 0; j < MODULE_SHORTCUT_MAX; j++ )
+
+ LOAD_IMMEDIATE( p_module->i_shortcuts );
+ if( p_module->i_shortcuts > MODULE_SHORTCUT_MAX )
+ goto error;
+ else if( p_module->i_shortcuts == 0 )
+ p_module->pp_shortcuts = NULL;
+ else
{
- LOAD_STRING( p_module->pp_shortcuts[j] ); // FIX
+ p_module->pp_shortcuts = xmalloc( sizeof( char ** ) * p_module->i_shortcuts );
+ for( j = 0; j < p_module->i_shortcuts; j++ )
+ LOAD_STRING( p_module->pp_shortcuts[j] );
}
+
LOAD_STRING( p_module->psz_capability );
LOAD_IMMEDIATE( p_module->i_score );
LOAD_IMMEDIATE( p_module->b_unloadable );
SAVE_STRING( pp_cache[i]->p_module->psz_shortname );
SAVE_STRING( pp_cache[i]->p_module->psz_longname );
SAVE_STRING( pp_cache[i]->p_module->psz_help );
- for (unsigned j = 0; j < MODULE_SHORTCUT_MAX; j++)
- {
- SAVE_STRING( pp_cache[i]->p_module->pp_shortcuts[j] ); // FIX
- }
+ SAVE_IMMEDIATE( pp_cache[i]->p_module->i_shortcuts );
+ for (unsigned j = 0; j < pp_cache[i]->p_module->i_shortcuts; j++)
+ SAVE_STRING( pp_cache[i]->p_module->pp_shortcuts[j] );
+
SAVE_STRING( pp_cache[i]->p_module->psz_capability );
SAVE_IMMEDIATE( pp_cache[i]->p_module->i_score );
SAVE_IMMEDIATE( pp_cache[i]->p_module->b_unloadable );
SAVE_STRING( p_module->psz_shortname );
SAVE_STRING( p_module->psz_longname );
SAVE_STRING( p_module->psz_help );
- for( unsigned j = 0; j < MODULE_SHORTCUT_MAX; j++ )
- SAVE_STRING( p_module->pp_shortcuts[j] ); // FIXME
+ SAVE_IMMEDIATE( p_module->i_shortcuts );
+ for( unsigned j = 0; j < p_module->i_shortcuts; j++ )
+ SAVE_STRING( p_module->pp_shortcuts[j] );
SAVE_STRING( p_module->psz_capability );
SAVE_IMMEDIATE( p_module->i_score );
{
module_t *module = vlc_priv (obj, module_t);
+ free (module->pp_shortcuts);
free (module->psz_object_name);
free (module);
}
module->psz_shortname = NULL;
module->psz_longname = (char*)default_name;
module->psz_help = NULL;
- for (unsigned i = 0; i < MODULE_SHORTCUT_MAX; i++)
- module->pp_shortcuts[i] = NULL;
+ module->pp_shortcuts = NULL;
+ module->i_shortcuts = 0;
module->psz_capability = (char*)"";
module->i_score = 1;
module->b_unloadable = true;
static void vlc_submodule_destruct (gc_object_t *obj)
{
module_t *module = vlc_priv (obj, module_t);
+ free (module->pp_shortcuts);
free (module->psz_object_name);
free (module);
}
module->submodule_count++;
/* Muahahaha! Heritage! Polymorphism! Ugliness!! */
+ submodule->pp_shortcuts = malloc( sizeof( char ** ) );
submodule->pp_shortcuts[0] = module->pp_shortcuts[0]; /* object name */
- for (unsigned i = 1; i < MODULE_SHORTCUT_MAX; i++)
- submodule->pp_shortcuts[i] = NULL;
+ submodule->i_shortcuts = 1;
submodule->psz_object_name = strdup( module->psz_object_name );
submodule->psz_shortname = module->psz_shortname;
case VLC_MODULE_SHORTCUT:
{
- unsigned i;
- for (i = 0; module->pp_shortcuts[i] != NULL; i++);
- if (i >= (MODULE_SHORTCUT_MAX - 1))
- break;
-
- module->pp_shortcuts[i] = va_arg (ap, char *);
+ 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;
break;
}
const char *value = va_arg (ap, const char *);
free( module->psz_object_name );
module->psz_object_name = strdup( value );
+ module->pp_shortcuts = malloc( sizeof( char ** ) );
module->pp_shortcuts[0] = (char*)value; /* dooh! */
+ module->i_shortcuts = 1;
+
if (module->psz_longname == default_name)
module->psz_longname = (char*)value; /* dooh! */
break;
for( unsigned i_short = i_shortcuts; i_short > 0; i_short-- )
{
- for( unsigned i = 0; p_module->pp_shortcuts[i]; i++ )
+ for( unsigned i = 0; i < p_module->i_shortcuts; i++ )
{
char *c;
if( ( c = strchr( name, '@' ) )
for (size_t i = 0; (module = list[i]) != NULL; i++)
{
- for (size_t j = 0;
- (module->pp_shortcuts[j] != NULL) && (j < MODULE_SHORTCUT_MAX);
- j++)
+ for (size_t j = 0; j < module->i_shortcuts; j++)
{
if (!strcmp (module->pp_shortcuts[j], psz_shortcut))
{
*****************************************************************************/
static void DupModule( module_t *p_module )
{
- char **pp_shortcut;
-
- for( pp_shortcut = p_module->pp_shortcuts ; *pp_shortcut ; pp_shortcut++ )
- {
- *pp_shortcut = strdup( *pp_shortcut );
- }
+ char **pp_shortcuts = p_module->pp_shortcuts;
+ for( unsigned i = 0; i < p_module->i_shortcuts; i++ )
+ pp_shortcuts[i] = strdup( p_module->pp_shortcuts[i] );
/* We strdup() these entries so that they are still valid when the
* module is unloaded. */
*****************************************************************************/
static void UndupModule( module_t *p_module )
{
- char **pp_shortcut;
+ char **pp_shortcuts = p_module->pp_shortcuts;
for (module_t *subm = p_module->submodule; subm; subm = subm->next)
UndupModule (subm);
- for( pp_shortcut = p_module->pp_shortcuts ; *pp_shortcut ; pp_shortcut++ )
- {
- free( *pp_shortcut );
- }
+ for( unsigned i = 0; i < p_module->i_shortcuts; i++ )
+ free( pp_shortcuts[i] );
free( p_module->psz_capability );
FREENULL( p_module->psz_shortname );
module_t *submodule;
unsigned submodule_count;
+ /** Shortcuts to the module */
+ unsigned i_shortcuts;
+ char **pp_shortcuts;
+
/*
* Variables set by the module to identify itself
*/
char *psz_longname; /**< Module descriptive name */
char *psz_help; /**< Long help string for "special" modules */
- /** Shortcuts to the module */
- char *pp_shortcuts[ MODULE_SHORTCUT_MAX ];
-
char *psz_capability; /**< Capability */
int i_score; /**< Score for the capability */