Commit 92290c9d authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Attempt to fix C++ compilation

parent 51ae5f27
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
/* Configuration hint types */ /* Configuration hint types */
#define CONFIG_HINT_END 0x0001 /* End of config */
#define CONFIG_HINT_CATEGORY 0x0002 /* Start of new category */ #define CONFIG_HINT_CATEGORY 0x0002 /* Start of new category */
#define CONFIG_HINT_SUBCATEGORY 0x0003 /* Start of sub-category */ #define CONFIG_HINT_SUBCATEGORY 0x0003 /* Start of sub-category */
#define CONFIG_HINT_SUBCATEGORY_END 0x0004 /* End of sub-category */ #define CONFIG_HINT_SUBCATEGORY_END 0x0004 /* End of sub-category */
...@@ -227,11 +226,11 @@ VLC_EXPORT( void, __config_ResetAll, ( vlc_object_t * ) ); ...@@ -227,11 +226,11 @@ VLC_EXPORT( void, __config_ResetAll, ( vlc_object_t * ) );
VLC_EXPORT( module_config_t *, config_FindConfig,( vlc_object_t *, const char * ) ); VLC_EXPORT( module_config_t *, config_FindConfig,( vlc_object_t *, const char * ) );
VLC_EXPORT( module_t *, config_FindModule,( vlc_object_t *, const char * ) ); VLC_EXPORT( module_t *, config_FindModule,( vlc_object_t *, const char * ) );
VLC_EXPORT( void, config_Duplicate, ( module_t *, const module_config_t * ) ); VLC_EXPORT( int, config_Duplicate, ( module_t *, const module_config_t *, size_t ) );
void config_Free ( module_t * ); void config_Free ( module_t * );
VLC_EXPORT( void, config_SetCallbacks, ( module_config_t *, module_config_t * ) ); VLC_EXPORT( void, config_SetCallbacks, ( module_config_t *, module_config_t *, size_t ) );
VLC_EXPORT( void, config_UnsetCallbacks, ( module_config_t * ) ); VLC_EXPORT( void, config_UnsetCallbacks, ( module_config_t *, size_t ) );
#define config_GetType(a,b) __config_GetType(VLC_OBJECT(a),b) #define config_GetType(a,b) __config_GetType(VLC_OBJECT(a),b)
#define config_GetInt(a,b) __config_GetInt(VLC_OBJECT(a),b) #define config_GetInt(a,b) __config_GetInt(VLC_OBJECT(a),b)
......
...@@ -112,6 +112,7 @@ struct module_t ...@@ -112,6 +112,7 @@ struct module_t
* Variables set by the module to store its config options * Variables set by the module to store its config options
*/ */
module_config_t *p_config; /* Module configuration structure */ module_config_t *p_config; /* Module configuration structure */
size_t confsize; /* Number of module_config_t items */
unsigned int i_config_items; /* number of configuration items */ unsigned int i_config_items; /* number of configuration items */
unsigned int i_bool_items; /* number of bool config items */ unsigned int i_bool_items; /* number of bool config items */
......
...@@ -102,10 +102,9 @@ E_(vlc_entry) ( module_t *p_module ); ...@@ -102,10 +102,9 @@ E_(vlc_entry) ( module_t *p_module );
EXTERN_SYMBOL DLL_SYMBOL int CDECL_SYMBOL \ EXTERN_SYMBOL DLL_SYMBOL int CDECL_SYMBOL \
__VLC_SYMBOL(vlc_entry) ( module_t *p_module ) \ __VLC_SYMBOL(vlc_entry) ( module_t *p_module ) \
{ \ { \
int i_shortcut = 1, i_config = -1; \ int i_shortcut = 1; \
size_t i_config = (size_t)(-1); \
module_config_t *p_config = NULL; \ module_config_t *p_config = NULL; \
static const module_config_t config_end = { \
.i_type = CONFIG_HINT_END }; \
STORE_SYMBOLS; \ STORE_SYMBOLS; \
p_module->b_submodule = VLC_FALSE; \ p_module->b_submodule = VLC_FALSE; \
p_module->b_unloadable = VLC_TRUE; \ p_module->b_unloadable = VLC_TRUE; \
...@@ -127,12 +126,9 @@ E_(vlc_entry) ( module_t *p_module ); ...@@ -127,12 +126,9 @@ E_(vlc_entry) ( module_t *p_module );
#define vlc_module_end( ) \ #define vlc_module_end( ) \
p_submodule->pp_shortcuts[ i_shortcut ] = NULL; \ p_submodule->pp_shortcuts[ i_shortcut ] = NULL; \
} \ } \
if( p_config ) \ if (config_Duplicate( p_module, p_config, ++i_config )) \
{ \ return VLC_ENOMEM; \
int i; \ for( size_t i = 0; i < i_config; i++ ) \
p_config[ ++i_config ] = config_end; \
config_Duplicate( p_module, p_config ); \
for( i = 0; i < i_config; i++ ) \
{ \ { \
if( p_config[ i ].i_action ) \ if( p_config[ i ].i_action ) \
{ \ { \
...@@ -141,13 +137,10 @@ E_(vlc_entry) ( module_t *p_module ); ...@@ -141,13 +137,10 @@ E_(vlc_entry) ( module_t *p_module );
} \ } \
} \ } \
free( p_config ); \ free( p_config ); \
} \
else config_Duplicate( p_module, &config_end ); \
if( p_module->p_config == NULL ) \ if( p_module->p_config == NULL ) \
{ \
return VLC_EGENERIC; \ return VLC_EGENERIC; \
} \ (void)i_shortcut; \
return VLC_SUCCESS && i_shortcut; \ return VLC_SUCCESS; \
} \ } \
struct _u_n_u_s_e_d_ /* the ; gets added */ struct _u_n_u_s_e_d_ /* the ; gets added */
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
# ifdef HAVE_SHARED_LIBVLC # ifdef HAVE_SHARED_LIBVLC
# error You are not supposed to include this file! # error You are not supposed to include this file!
# endif # endif
/* /*
* This is the big VLC API structure for plugins : * This is the big VLC API structure for plugins :
* Changing its layout breaks plugin's binary compatibility, * Changing its layout breaks plugin's binary compatibility,
...@@ -71,9 +70,9 @@ struct module_symbols_t ...@@ -71,9 +70,9 @@ struct module_symbols_t
void (*__config_ResetAll_inner) (vlc_object_t *); void (*__config_ResetAll_inner) (vlc_object_t *);
module_config_t * (*config_FindConfig_inner) (vlc_object_t *, const char *); module_config_t * (*config_FindConfig_inner) (vlc_object_t *, const char *);
module_t * (*config_FindModule_inner) (vlc_object_t *, const char *); module_t * (*config_FindModule_inner) (vlc_object_t *, const char *);
void (*config_Duplicate_inner) (module_t *, const module_config_t *); int (*config_Duplicate_inner) (module_t *, const module_config_t *, size_t);
void (*config_SetCallbacks_inner) (module_config_t *, module_config_t *); void (*config_SetCallbacks_inner) (module_config_t *, module_config_t *, size_t);
void (*config_UnsetCallbacks_inner) (module_config_t *); void (*config_UnsetCallbacks_inner) (module_config_t *, size_t);
int (*__intf_Eject_inner) (vlc_object_t *, const char *); int (*__intf_Eject_inner) (vlc_object_t *, const char *);
const iso639_lang_t * (*GetLang_1_inner) (const char *); const iso639_lang_t * (*GetLang_1_inner) (const char *);
const iso639_lang_t * (*GetLang_2T_inner) (const char *); const iso639_lang_t * (*GetLang_2T_inner) (const char *);
......
...@@ -333,7 +333,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] ) ...@@ -333,7 +333,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] )
} }
p_help_module->psz_object_name = "help"; p_help_module->psz_object_name = "help";
p_help_module->psz_longname = N_("Help options"); p_help_module->psz_longname = N_("Help options");
config_Duplicate( p_help_module, p_help_config ); config_Duplicate( p_help_module, p_help_config,
sizeof (p_help_config) / sizeof (p_help_config[0]) );
vlc_object_attach( p_help_module, libvlc_global.p_module_bank ); vlc_object_attach( p_help_module, libvlc_global.p_module_bank );
/* End hack */ /* End hack */
...@@ -1346,7 +1347,6 @@ static void Usage( libvlc_int_t *p_this, char const *psz_module_name ) ...@@ -1346,7 +1347,6 @@ static void Usage( libvlc_int_t *p_this, char const *psz_module_name )
#endif #endif
vlc_list_t *p_list; vlc_list_t *p_list;
module_t *p_parser; module_t *p_parser;
module_config_t *p_item;
char psz_spaces_text[PADDING_SPACES+LINE_START+1]; char psz_spaces_text[PADDING_SPACES+LINE_START+1];
char psz_spaces_longtext[LINE_START+3]; char psz_spaces_longtext[LINE_START+3];
char psz_format[sizeof(FORMAT_STRING)]; char psz_format[sizeof(FORMAT_STRING)];
...@@ -1371,8 +1371,9 @@ static void Usage( libvlc_int_t *p_this, char const *psz_module_name ) ...@@ -1371,8 +1371,9 @@ static void Usage( libvlc_int_t *p_this, char const *psz_module_name )
for( i_index = 0; i_index < p_list->i_count; i_index++ ) for( i_index = 0; i_index < p_list->i_count; i_index++ )
{ {
vlc_bool_t b_help_module; vlc_bool_t b_help_module;
module_t *p_parser = (module_t *)p_list->p_values[i_index].p_object;
p_parser = (module_t *)p_list->p_values[i_index].p_object ; module_config_t *p_item,
*p_end = p_parser->p_config + p_parser->confsize;
if( psz_module_name && strcmp( psz_module_name, if( psz_module_name && strcmp( psz_module_name,
p_parser->psz_object_name ) ) p_parser->psz_object_name ) )
...@@ -1390,13 +1391,12 @@ static void Usage( libvlc_int_t *p_this, char const *psz_module_name ) ...@@ -1390,13 +1391,12 @@ static void Usage( libvlc_int_t *p_this, char const *psz_module_name )
if( !b_advanced ) if( !b_advanced )
{ {
for( p_item = p_parser->p_config; for( p_item = p_parser->p_config;
p_item->i_type != CONFIG_HINT_END; p_item < p_end;
p_item++ ) p_item++ )
{ {
if( (p_item->i_type & CONFIG_ITEM) && if( (p_item->i_type & CONFIG_ITEM) &&
!p_item->b_advanced ) break; !p_item->b_advanced ) break;
} }
if( p_item->i_type == CONFIG_HINT_END ) continue;
} }
/* Print name of module */ /* Print name of module */
...@@ -1407,7 +1407,7 @@ static void Usage( libvlc_int_t *p_this, char const *psz_module_name ) ...@@ -1407,7 +1407,7 @@ static void Usage( libvlc_int_t *p_this, char const *psz_module_name )
/* Print module options */ /* Print module options */
for( p_item = p_parser->p_config; for( p_item = p_parser->p_config;
p_item->i_type != CONFIG_HINT_END; p_item < p_end;
p_item++ ) p_item++ )
{ {
char *psz_text, *psz_spaces = psz_spaces_text; char *psz_text, *psz_spaces = psz_spaces_text;
......
...@@ -2213,8 +2213,7 @@ static module_config_t p_help_config[] = ...@@ -2213,8 +2213,7 @@ static module_config_t p_help_config[] =
.i_type = CONFIG_ITEM_BOOL, .i_type = CONFIG_ITEM_BOOL,
.psz_name = "version", .psz_name = "version",
.psz_text = N_("print version information") .psz_text = N_("print version information")
}, }
{ .i_type = CONFIG_HINT_END }
}; };
/***************************************************************************** /*****************************************************************************
......
...@@ -424,8 +424,6 @@ void __config_PutFloat( vlc_object_t *p_this, ...@@ -424,8 +424,6 @@ void __config_PutFloat( vlc_object_t *p_this,
module_config_t *config_FindConfig( vlc_object_t *p_this, const char *psz_name ) module_config_t *config_FindConfig( vlc_object_t *p_this, const char *psz_name )
{ {
vlc_list_t *p_list; vlc_list_t *p_list;
module_t *p_parser;
module_config_t *p_item;
int i_index; int i_index;
if( !psz_name ) return NULL; if( !psz_name ) return NULL;
...@@ -434,13 +432,14 @@ module_config_t *config_FindConfig( vlc_object_t *p_this, const char *psz_name ) ...@@ -434,13 +432,14 @@ module_config_t *config_FindConfig( vlc_object_t *p_this, const char *psz_name )
for( i_index = 0; i_index < p_list->i_count; i_index++ ) for( i_index = 0; i_index < p_list->i_count; i_index++ )
{ {
p_parser = (module_t *)p_list->p_values[i_index].p_object ; module_config_t *p_item, *p_end;
module_t *p_parser = (module_t *)p_list->p_values[i_index].p_object;
if( !p_parser->i_config_items ) if( !p_parser->i_config_items )
continue; continue;
for( p_item = p_parser->p_config; for( p_item = p_parser->p_config, p_end = p_item + p_parser->confsize;
p_item->i_type != CONFIG_HINT_END; p_item < p_end;
p_item++ ) p_item++ )
{ {
if( p_item->i_type & CONFIG_HINT ) if( p_item->i_type & CONFIG_HINT )
...@@ -494,19 +493,18 @@ module_t *config_FindModule( vlc_object_t *p_this, const char *psz_name ) ...@@ -494,19 +493,18 @@ module_t *config_FindModule( vlc_object_t *p_this, const char *psz_name )
* this module might be unloaded from memory at any time (remember HideModule). * this module might be unloaded from memory at any time (remember HideModule).
* This is why we need to create an exact copy of the config data. * This is why we need to create an exact copy of the config data.
*****************************************************************************/ *****************************************************************************/
void config_Duplicate( module_t *p_module, const module_config_t *p_orig ) int config_Duplicate( module_t *p_module, const module_config_t *p_orig,
size_t n )
{ {
int i, j, i_lines = 1; int j;
const module_config_t *p_item; const module_config_t *p_item, *p_end = p_orig + n;
/* Calculate the structure length */ /* Calculate the structure length */
p_module->i_config_items = 0; p_module->i_config_items = 0;
p_module->i_bool_items = 0; p_module->i_bool_items = 0;
for( p_item = p_orig; p_item->i_type != CONFIG_HINT_END; p_item++ ) for( p_item = p_orig; p_item < p_end; p_item++ )
{ {
i_lines++;
if( p_item->i_type & CONFIG_ITEM ) if( p_item->i_type & CONFIG_ITEM )
{ {
p_module->i_config_items++; p_module->i_config_items++;
...@@ -519,16 +517,16 @@ void config_Duplicate( module_t *p_module, const module_config_t *p_orig ) ...@@ -519,16 +517,16 @@ void config_Duplicate( module_t *p_module, const module_config_t *p_orig )
} }
/* Allocate memory */ /* Allocate memory */
p_module->p_config = (module_config_t *)malloc( sizeof(module_config_t) p_module->p_config = (module_config_t *)calloc( n, sizeof(*p_orig) );
* i_lines );
if( p_module->p_config == NULL ) if( p_module->p_config == NULL )
{ {
msg_Err( p_module, "config error: can't duplicate p_config" ); msg_Err( p_module, "config error: can't duplicate p_config" );
return; return VLC_ENOMEM;
} }
p_module->confsize = n;
/* Do the duplication job */ /* Do the duplication job */
for( i = 0; i < i_lines ; i++ ) for( size_t i = 0; i < n ; i++ )
{ {
p_module->p_config[i] = p_orig[i]; p_module->p_config[i] = p_orig[i];
...@@ -630,16 +628,12 @@ void config_Duplicate( module_t *p_module, const module_config_t *p_orig ) ...@@ -630,16 +628,12 @@ void config_Duplicate( module_t *p_module, const module_config_t *p_orig )
*****************************************************************************/ *****************************************************************************/
void config_Free( module_t *p_module ) void config_Free( module_t *p_module )
{ {
module_config_t *p_item = p_module->p_config;
int i; int i;
if( p_item == NULL ) for (size_t j = 0; j < p_module->confsize; j++)
{ {
return; module_config_t *p_item = p_module->p_config + j;
}
for( ; p_item->i_type != CONFIG_HINT_END ; p_item++ )
{
if( p_item->psz_type ) if( p_item->psz_type )
free( p_item->psz_type ); free( p_item->psz_type );
...@@ -688,8 +682,11 @@ void config_Free( module_t *p_module ) ...@@ -688,8 +682,11 @@ void config_Free( module_t *p_module )
} }
} }
free( p_module->p_config ); if (p_module->p_config != NULL)
{
free (p_module->p_config);
p_module->p_config = NULL; p_module->p_config = NULL;
}
} }
/***************************************************************************** /*****************************************************************************
...@@ -699,9 +696,10 @@ void config_Free( module_t *p_module ) ...@@ -699,9 +696,10 @@ void config_Free( module_t *p_module )
* this module might be unloaded from memory at any time (remember HideModule). * this module might be unloaded from memory at any time (remember HideModule).
* This is why we need to duplicate callbacks each time we reload the module. * This is why we need to duplicate callbacks each time we reload the module.
*****************************************************************************/ *****************************************************************************/
void config_SetCallbacks( module_config_t *p_new, module_config_t *p_orig ) void config_SetCallbacks( module_config_t *p_new, module_config_t *p_orig,
size_t n )
{ {
while( p_new->i_type != CONFIG_HINT_END ) for (size_t i = 0; i < n; i++)
{ {
p_new->pf_callback = p_orig->pf_callback; p_new->pf_callback = p_orig->pf_callback;
p_new++; p_new++;
...@@ -714,9 +712,9 @@ void config_SetCallbacks( module_config_t *p_new, module_config_t *p_orig ) ...@@ -714,9 +712,9 @@ void config_SetCallbacks( module_config_t *p_new, module_config_t *p_orig )
***************************************************************************** *****************************************************************************
* We simply undo what we did in config_SetCallbacks. * We simply undo what we did in config_SetCallbacks.
*****************************************************************************/ *****************************************************************************/
void config_UnsetCallbacks( module_config_t *p_new ) void config_UnsetCallbacks( module_config_t *p_new, size_t n )
{ {
while( p_new->i_type != CONFIG_HINT_END ) for (size_t i = 0; i < n; i++)
{ {
p_new->pf_callback = NULL; p_new->pf_callback = NULL;
p_new++; p_new++;
...@@ -728,7 +726,7 @@ void config_UnsetCallbacks( module_config_t *p_new ) ...@@ -728,7 +726,7 @@ void config_UnsetCallbacks( module_config_t *p_new )
*****************************************************************************/ *****************************************************************************/
void __config_ResetAll( vlc_object_t *p_this ) void __config_ResetAll( vlc_object_t *p_this )
{ {
int i_index, i; int i_index;
vlc_list_t *p_list; vlc_list_t *p_list;
module_t *p_module; module_t *p_module;
...@@ -742,7 +740,7 @@ void __config_ResetAll( vlc_object_t *p_this ) ...@@ -742,7 +740,7 @@ void __config_ResetAll( vlc_object_t *p_this )
p_module = (module_t *)p_list->p_values[i_index].p_object ; p_module = (module_t *)p_list->p_values[i_index].p_object ;
if( p_module->b_submodule ) continue; if( p_module->b_submodule ) continue;
for( i = 0; p_module->p_config[i].i_type != CONFIG_HINT_END; i++ ) for (size_t i = 0; i < p_module->confsize; i++ )
{ {
if (IsConfigIntegerType (p_module->p_config[i].i_type)) if (IsConfigIntegerType (p_module->p_config[i].i_type))
p_module->p_config[i].value.i = p_module->p_config[i].orig.i; p_module->p_config[i].value.i = p_module->p_config[i].orig.i;
...@@ -868,7 +866,7 @@ int __config_LoadConfigFile( vlc_object_t *p_this, const char *psz_module_name ) ...@@ -868,7 +866,7 @@ int __config_LoadConfigFile( vlc_object_t *p_this, const char *psz_module_name )
while( fgets( line, 1024, file ) ) while( fgets( line, 1024, file ) )
{ {
const char *psz_option_name, *psz_option_value; const char *psz_option_name, *psz_option_value;
module_config_t *p_item; module_config_t *p_item, *p_end;
if( line[0] == '[' ) break; /* end of section */ if( line[0] == '[' ) break; /* end of section */
...@@ -895,8 +893,8 @@ int __config_LoadConfigFile( vlc_object_t *p_this, const char *psz_module_name ) ...@@ -895,8 +893,8 @@ int __config_LoadConfigFile( vlc_object_t *p_this, const char *psz_module_name )
} }
/* try to match this option with one of the module's options */ /* try to match this option with one of the module's options */
for( p_item = p_parser->p_config; for( p_item = p_parser->p_config, p_end = p_item + p_parser->confsize;
p_item->i_type != CONFIG_HINT_END; p_item < p_end;
p_item++ ) p_item++ )
{ {
if( p_item->i_type & CONFIG_HINT ) if( p_item->i_type & CONFIG_HINT )
...@@ -1018,7 +1016,6 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name, ...@@ -1018,7 +1016,6 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
{ {
module_t *p_parser; module_t *p_parser;
vlc_list_t *p_list; vlc_list_t *p_list;
module_config_t *p_item;
FILE *file; FILE *file;
char p_line[1024], *p_index2; char p_line[1024], *p_index2;
int i_sizebuf = 0; int i_sizebuf = 0;
...@@ -1175,6 +1172,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name, ...@@ -1175,6 +1172,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
/* Look for the selected module, if NULL then save everything */ /* Look for the selected module, if NULL then save everything */
for( i_index = 0; i_index < p_list->i_count; i_index++ ) for( i_index = 0; i_index < p_list->i_count; i_index++ )
{ {
module_config_t *p_item, *p_end;
p_parser = (module_t *)p_list->p_values[i_index].p_object ; p_parser = (module_t *)p_list->p_values[i_index].p_object ;
if( psz_module_name && strcmp( psz_module_name, if( psz_module_name && strcmp( psz_module_name,
...@@ -1194,8 +1192,8 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name, ...@@ -1194,8 +1192,8 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
else else
fprintf( file, "\n\n" ); fprintf( file, "\n\n" );
for( p_item = p_parser->p_config; for( p_item = p_parser->p_config, p_end = p_item + p_parser->confsize;
p_item->i_type != CONFIG_HINT_END; p_item < p_end;
p_item++ ) p_item++ )
{ {
char *psz_key; char *psz_key;
...@@ -1309,8 +1307,6 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name, ...@@ -1309,8 +1307,6 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
int config_AutoSaveConfigFile( vlc_object_t *p_this ) int config_AutoSaveConfigFile( vlc_object_t *p_this )
{ {
vlc_list_t *p_list; vlc_list_t *p_list;
module_t *p_parser;
module_config_t *p_item;
int i_index, i_count; int i_index, i_count;
/* Check if there's anything to save */ /* Check if there's anything to save */
...@@ -1319,17 +1315,18 @@ int config_AutoSaveConfigFile( vlc_object_t *p_this ) ...@@ -1319,17 +1315,18 @@ int config_AutoSaveConfigFile( vlc_object_t *p_this )
i_count = p_list->i_count; i_count = p_list->i_count;
for( i_index = 0; i_index < i_count; i_index++ ) for( i_index = 0; i_index < i_count; i_index++ )
{ {
p_parser = (module_t *)p_list->p_values[i_index].p_object ; module_t *p_parser = (module_t *)p_list->p_values[i_index].p_object ;
module_config_t *p_item, *p_end;
if( !p_parser->i_config_items ) continue; if( !p_parser->i_config_items ) continue;
for( p_item = p_parser->p_config; for( p_item = p_parser->p_config, p_end = p_item + p_parser->confsize;
p_item->i_type != CONFIG_HINT_END; p_item < p_end;
p_item++ ) p_item++ )
{ {
if( p_item->b_autosave && p_item->b_dirty ) break; if( p_item->b_autosave && p_item->b_dirty ) break;
} }
if( p_item->i_type != CONFIG_HINT_END ) break; break;
} }
vlc_list_release( p_list ); vlc_list_release( p_list );
vlc_mutex_unlock( &p_this->p_libvlc->config_lock ); vlc_mutex_unlock( &p_this->p_libvlc->config_lock );
...@@ -1358,7 +1355,6 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc, char *ppsz_argv[], ...@@ -1358,7 +1355,6 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc, char *ppsz_argv[],
int i_cmd, i_index, i_opts, i_shortopts, flag, i_verbose = 0; int i_cmd, i_index, i_opts, i_shortopts, flag, i_verbose = 0;
module_t *p_parser; module_t *p_parser;
vlc_list_t *p_list; vlc_list_t *p_list;
module_config_t *p_item;
struct option *p_longopts; struct option *p_longopts;
int i_modules_index; int i_modules_index;
...@@ -1456,13 +1452,14 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc, char *ppsz_argv[], ...@@ -1456,13 +1452,14 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc, char *ppsz_argv[],
for( i_modules_index = 0; i_modules_index < p_list->i_count; for( i_modules_index = 0; i_modules_index < p_list->i_count;
i_modules_index++ ) i_modules_index++ )
{ {
module_config_t *p_item, *p_end;
p_parser = (module_t *)p_list->p_values[i_modules_index].p_object ; p_parser = (module_t *)p_list->p_values[i_modules_index].p_object ;
if( !p_parser->i_config_items ) if( !p_parser->i_config_items )
continue; continue;
for( p_item = p_parser->p_config; for( p_item = p_parser->p_config, p_end = p_item + p_parser->confsize;
p_item->i_type != CONFIG_HINT_END; p_item < p_end;
p_item++ ) p_item++ )
{ {
/* Ignore hints */ /* Ignore hints */
......
...@@ -1014,7 +1014,7 @@ static int AllocatePluginFile( vlc_object_t * p_this, char * psz_file, ...@@ -1014,7 +1014,7 @@ static int AllocatePluginFile( vlc_object_t * p_this, char * psz_file,
} }
else else
{ {
module_config_t *p_item; module_config_t *p_item, *p_end;
p_module = p_cache_entry->p_module; p_module = p_cache_entry->p_module;
p_module->b_loaded = VLC_FALSE; p_module->b_loaded = VLC_FALSE;
...@@ -1022,8 +1022,8 @@ static int AllocatePluginFile( vlc_object_t * p_this, char * psz_file, ...@@ -1022,8 +1022,8 @@ static int AllocatePluginFile( vlc_object_t * p_this, char * psz_file,
/* For now we force loading if the module's config contains /* For now we force loading if the module's config contains
* callbacks or actions. * callbacks or actions.
* Could be optimized by adding an API call.*/ * Could be optimized by adding an API call.*/
for( p_item = p_module->p_config; for( p_item = p_module->p_config, p_end = p_item + p_module->confsize;
p_item->i_type != CONFIG_HINT_END; p_item++ ) p_item < p_end; p_item++ )
{ {
if( p_item->pf_callback || p_item->i_action ) if( p_item->pf_callback || p_item->i_action )
p_module = AllocatePlugin( p_this, psz_file ); p_module = AllocatePlugin( p_this, psz_file );
...@@ -1809,13 +1809,16 @@ int CacheLoadConfig( module_t *p_module, FILE *file ) ...@@ -1809,13 +1809,16 @@ int CacheLoadConfig( module_t *p_module, FILE *file )
LOAD_IMMEDIATE( i_lines ); LOAD_IMMEDIATE( i_lines );
/* Allocate memory */ /* Allocate memory */
if (i_lines)
{
p_module->p_config = p_module->p_config =
(module_config_t *)malloc( sizeof(module_config_t) * (i_lines + 1)); (module_config_t *)calloc( i_lines, sizeof(module_config_t) );
if( p_module->p_config == NULL ) if( p_module->p_config == NULL )
{ {
msg_Err( p_module, "config error: can't duplicate p_config" ); msg_Err( p_module, "config error: can't duplicate p_config" );
return VLC_ENOMEM; return VLC_ENOMEM;
} }
}
/* Do the duplication job */ /* Do the duplication job */
for( i = 0; i < i_lines ; i++ ) for( i = 0; i < i_lines ; i++ )
...@@ -1901,8 +1904,6 @@ int CacheLoadConfig( module_t *p_module, FILE *file ) ...@@ -1901,8 +1904,6 @@ int CacheLoadConfig( module_t *p_module, FILE *file )
LOAD_IMMEDIATE( p_module->p_config[i].pf_callback ); LOAD_IMMEDIATE( p_module->p_config[i].pf_callback );
} }
p_module->p_config[i].i_type = CONFIG_HINT_END;
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
...@@ -2078,13 +2079,14 @@ static void CacheSave( vlc_object_t *p_this ) ...@@ -2078,13 +2079,14 @@ static void CacheSave( vlc_object_t *p_this )
void CacheSaveConfig( module_t *p_module, FILE *file ) void CacheSaveConfig( module_t *p_module, FILE *file )
{ {
int i, j, i_lines = 0; int i, j, i_lines = 0;
module_config_t *p_item; module_config_t *p_item, *p_end;
uint16_t i_size; uint16_t i_size;
SAVE_IMMEDIATE( p_module->i_config_items ); SAVE_IMMEDIATE( p_module->i_config_items );
SAVE_IMMEDIATE( p_module->i_bool_items ); SAVE_IMMEDIATE( p_module->i_bool_items );
for( p_item = p_module->p_config; p_item->i_type != CONFIG_HINT_END; for( p_item = p_module->p_config, p_end = p_item + p_module->confsize;
p_item < p_end;
p_item++ ) i_lines++; p_item++ ) i_lines++;
SAVE_IMMEDIATE( i_lines ); SAVE_IMMEDIATE( i_lines );
......
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