Commit 927f27d8 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Save one memory copy and fix the helper module leak

parent cbe2c267
......@@ -121,14 +121,10 @@ E_(vlc_entry) ( module_t *p_module );
#define vlc_module_end( ) \
} \
res = config_Duplicate( p_module, p_config, ++i_config ); \
free( p_config ); \
if (res) \
return res; \
return VLC_SUCCESS; \
return config_Duplicate( p_module, p_config, ++i_config ); \
\
error: \
free( p_config ); \
/* FIXME: config_Free( p_config ); */ \
/* FIXME: cleanup submodules objects ??? */ \
return VLC_EGENERIC; \
} \
......
......@@ -492,9 +492,6 @@ int config_Duplicate( module_t *p_module, const module_config_t *p_orig,
const module_config_t *p_item, *p_end = p_orig + n;
/* Calculate the structure length */
p_module->i_config_items = 0;
p_module->i_bool_items = 0;
for( p_item = p_orig; p_item < p_end; p_item++ )
{
if( p_item->i_type & CONFIG_ITEM )
......@@ -508,19 +505,12 @@ int config_Duplicate( module_t *p_module, const module_config_t *p_orig,
}
}
/* Allocate memory */
p_module->p_config = (module_config_t *)calloc( n, sizeof(*p_orig) );
if( p_module->p_config == NULL )
{
msg_Err( p_module, "config error: can't duplicate p_config" );
return VLC_ENOMEM;
}
p_module->p_config = p_orig;
p_module->confsize = n;
/* Do the duplication job */
for( size_t i = 0; i < n ; i++ )
{
p_module->p_config[i] = p_orig[i];
p_module->p_config[i].p_lock = &p_module->object_lock;
}
return VLC_SUCCESS;
......
......@@ -40,6 +40,8 @@ module_t *vlc_module_create (vlc_object_t *obj)
module->psz_object_name = module->psz_longname = default_name;
module->psz_capability = "";
module->i_score = 1;
module->i_config_items = module->i_bool_items = 0;
return module;
}
......@@ -161,6 +163,13 @@ module_config_t *vlc_config_create (module_t *module, int type)
tab[confsize].i_type = type;
tab[confsize].p_lock = &module->object_lock;
if (type & CONFIG_ITEM)
{
module->i_config_items++;
if (type == CONFIG_ITEM_BOOL)
module->i_bool_items++;
}
return tab + confsize;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment