Use NULL rather than a static string as the default.
module_get_object() deals with this situation.
*****************************************************************************/
static int SaveConfigFile (vlc_object_t *p_this)
{
- module_t *p_parser;
char *permanent = NULL, *temporary = NULL;
if( config_PrepareDir( p_this ) )
if ((line[0] == '[') && (p_index2 = strchr(line,']')))
{
+ module_t *module;
+
/* we found a new section, check if we need to do a backup */
backup = true;
- for (int i = 0; (p_parser = list[i]) != NULL; i++)
+ for (int i = 0; (module = list[i]) != NULL; i++)
{
- if (!strncmp (line + 1, p_parser->psz_object_name,
- strlen (p_parser->psz_object_name)))
+ const char *objname = module_get_object (module);
+
+ if (!strncmp (line + 1, objname, strlen (objname)))
{
backup = false; /* no, we will rewrite it! */
break;
vlc_rwlock_rdlock (&config_lock);*/
/* Look for the selected module, if NULL then save everything */
+ module_t *p_parser;
for (int i = 0; (p_parser = list[i]) != NULL; i++)
{
module_config_t *p_item, *p_end;
if( !p_parser->i_config_items )
continue;
- fprintf( file, "[%s]", p_parser->psz_object_name );
+ fprintf( file, "[%s]", module_get_object (p_parser) );
if( p_parser->psz_longname )
fprintf( file, " # %s\n\n", p_parser->psz_longname );
else
module_config_t *p_item = NULL;
module_config_t *p_section = NULL;
module_config_t *p_end = p_parser->p_config + p_parser->confsize;
+ const char *objname = module_get_object (p_parser);
if( psz_search &&
- ( b_strict ? strcmp( psz_search, p_parser->psz_object_name )
- : !strstr( p_parser->psz_object_name, psz_search ) ) )
+ ( b_strict ? strcmp( objname, psz_search )
+ : !strstr( objname, psz_search ) ) )
{
char *const *pp_shortcuts = p_parser->pp_shortcuts;
unsigned i;
continue;
}
- b_help_module = !strcmp( "help", p_parser->psz_object_name );
+ b_help_module = !strcmp( "help", objname );
/* Ugly hack to make sure that the help options always come first
* (part 2) */
if( !psz_search && b_help_module )
b_found = true;
/* Print name of module */
- if( strcmp( "main", p_parser->psz_object_name ) )
+ if( strcmp( "main", objname ) )
{
if( b_color )
utf8_fprintf( stdout, "\n " GREEN "%s" GRAY " (%s)\n",
module_gettext( p_parser, p_parser->psz_longname ),
- p_parser->psz_object_name );
+ objname );
else
utf8_fprintf( stdout, "\n %s\n",
module_gettext(p_parser, p_parser->psz_longname ) );
{
case CONFIG_HINT_CATEGORY:
case CONFIG_HINT_USAGE:
- if( !strcmp( "main", p_parser->psz_object_name ) )
+ if( !strcmp( "main", objname ) )
{
if( b_color )
utf8_fprintf( stdout, GREEN "\n %s\n" GRAY,
break;
case CONFIG_HINT_SUBCATEGORY:
- if( strcmp( "main", p_parser->psz_object_name ) )
+ if( strcmp( "main", objname ) )
break;
case CONFIG_SECTION:
p_section = p_item;
/* Enumerate each module */
for (size_t j = 0; (p_parser = list[j]) != NULL; j++)
{
+ const char *objname = module_get_object (p_parser);
if( b_color )
- utf8_fprintf( stdout, GREEN" %-22s "WHITE"%s\n"GRAY,
- p_parser->psz_object_name,
+ utf8_fprintf( stdout, GREEN" %-22s "WHITE"%s\n"GRAY, objname,
module_gettext( p_parser, p_parser->psz_longname ) );
else
- utf8_fprintf( stdout, " %-22s %s\n",
- p_parser->psz_object_name,
+ utf8_fprintf( stdout, " %-22s %s\n", objname,
module_gettext( p_parser, p_parser->psz_longname ) );
if( b_verbose )
char *const *pp_shortcuts = p_parser->pp_shortcuts;
for( unsigned i = 0; i < p_parser->i_shortcuts; i++ )
{
- if( strcmp( pp_shortcuts[i], p_parser->psz_object_name ) )
+ if( strcmp( pp_shortcuts[i], objname ) )
{
if( b_color )
utf8_fprintf( stdout, CYAN" s %s\n"GRAY,
module = vlc_module_create();
/* Load additional infos */
- free (module->psz_object_name);
- LOAD_STRING(module->psz_object_name);
+ LOAD_STRING(module->object_name);
LOAD_STRING(module->psz_shortname);
LOAD_STRING(module->psz_longname);
LOAD_STRING(module->psz_help);
while( i_submodules-- )
{
module_t *submodule = vlc_submodule_create (module);
- free (submodule->psz_object_name);
+ free (submodule->object_name);
free (submodule->pp_shortcuts);
- LOAD_STRING(submodule->psz_object_name);
+ LOAD_STRING(submodule->object_name);
LOAD_STRING(submodule->psz_shortname);
LOAD_STRING(submodule->psz_longname);
LOAD_STRING(submodule->psz_help);
uint32_t i_submodule;
/* Save additional infos */
- SAVE_STRING(module->psz_object_name);
+ SAVE_STRING(module->object_name);
SAVE_STRING(module->psz_shortname);
SAVE_STRING(module->psz_longname);
SAVE_STRING(module->psz_help);
if( CacheSaveSubmodule( file, p_module->next ) )
goto error;
- SAVE_STRING( p_module->psz_object_name );
+ SAVE_STRING( p_module->object_name );
SAVE_STRING( p_module->psz_shortname );
SAVE_STRING( p_module->psz_longname );
SAVE_STRING( p_module->psz_help );
module_t *module = vlc_priv (obj, module_t);
free (module->pp_shortcuts);
- free (module->psz_object_name);
+ free (module->object_name);
free (module);
}
-static const char default_name[] = "unnamed";
-
module_t *vlc_module_create (void)
{
module_t *module = malloc (sizeof (*module));
if (module == NULL)
return NULL;
- module->psz_object_name = strdup( default_name );
+ module->object_name = NULL;
module->next = NULL;
module->submodule = NULL;
module->parent = NULL;
vlc_gc_init (module, vlc_module_destruct);
module->psz_shortname = NULL;
- module->psz_longname = (char*)default_name;
+ module->psz_longname = NULL;
module->psz_help = NULL;
module->pp_shortcuts = NULL;
module->i_shortcuts = 0;
{
module_t *module = vlc_priv (obj, module_t);
free (module->pp_shortcuts);
- free (module->psz_object_name);
+ free (module->object_name);
free (module);
}
submodule->pp_shortcuts[0] = module->pp_shortcuts[0]; /* object name */
submodule->i_shortcuts = 1;
- submodule->psz_object_name = strdup( module->psz_object_name );
+ submodule->object_name = strdup (module->object_name);
submodule->psz_shortname = module->psz_shortname;
submodule->psz_longname = module->psz_longname;
submodule->psz_capability = module->psz_capability;
case VLC_MODULE_NAME:
{
const char *value = va_arg (ap, const char *);
- free( module->psz_object_name );
- module->psz_object_name = strdup( value );
+
+ assert (module->object_name == NULL);
+ module->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)
+ if (module->psz_longname == NULL)
module->psz_longname = (char*)value; /* dooh! */
break;
}
*/
const char *module_get_object( const module_t *m )
{
- return m->psz_object_name;
+ if (unlikely(m->object_name == NULL))
+ return "unnamed";
+ return m->object_name;
}
/**
if( long_name && ( m->psz_longname != NULL) )
return m->psz_longname;
- return m->psz_shortname ? m->psz_shortname : m->psz_object_name;
+ if (m->psz_shortname != NULL)
+ return m->psz_shortname;
+ return module_get_object (m);
}
/**
if( p_module != NULL )
{
msg_Dbg( p_this, "using %s module \"%s\"",
- psz_capability, p_module->psz_object_name );
+ psz_capability, module_get_object(p_module) );
vlc_object_set_name( p_this, psz_alias ? psz_alias
- : p_module->psz_object_name );
+ : module_get_object(p_module) );
}
else if( count == 0 )
msg_Dbg( p_this, "no %s module matched \"%s\"",
#undef module_unneed
void module_unneed(vlc_object_t *obj, module_t *module)
{
- msg_Dbg(obj, "removing module \"%s\"", module->psz_object_name);
+ msg_Dbg(obj, "removing module \"%s\"", module_get_object(module));
vlc_module_unload(module, generic_stop, obj);
}
/**
* Get a pointer to a module_t given it's name.
*
- * \param psz_name the name of the module
+ * \param name the name of the module
* \return a pointer to the module or NULL in case of a failure
*/
-module_t *module_find( const char * psz_name )
+module_t *module_find (const char *name)
{
module_t **list, *module;
+ assert (name != NULL);
list = module_list_get (NULL);
if (!list)
return NULL;
for (size_t i = 0; (module = list[i]) != NULL; i++)
{
- const char *psz_module_name = module->psz_object_name;
+ const char *objname = module->object_name;
- if( psz_module_name && !strcmp( psz_module_name, psz_name ) )
+ if (unlikely(objname == NULL))
+ continue;
+ if (!strcmp (objname, name))
{
module_hold (module);
break;
{
module_t * p_module = NULL;
- /* msg_Dbg( p_this, "plugin \"%s\", %s",
- p_module->psz_object_name, p_module->psz_longname ); */
/* Check our plugins cache first then load plugin if needed */
if( mode == CACHE_USE )
p_module = CacheFind (p_bank->loaded_cache, p_bank->i_loaded_cache,
if( p_module == NULL )
return -1;
- /* Initialize the module : fill p_module->psz_object_name, etc. */
+ /* Initialize the module : fill *p_module structure */
if( pf_entry( p_module ) != 0 )
{
/* With a well-written module we shouldn't have to print an
modules.head = p_module;
/* UNLOCK */
- /* msg_Dbg( p_this, "builtin \"%s\", %s",
- p_module->psz_object_name, p_module->psz_longname ); */
-
return 0;
}
*/
struct module_t
{
- char *psz_object_name;
+ char *object_name;
gc_object_t vlc_gc_data;
module_t *next;