diff --git a/common/config/config_cmdline.c b/common/config/config_cmdline.c index 2e6b21dea4cd0bbc91b109dc5514351a64947b67..3bd41cf6cc481239a379a616553b3f878ae5a840 100644 --- a/common/config/config_cmdline.c +++ b/common/config/config_cmdline.c @@ -142,25 +142,16 @@ char defbool[2]="1"; int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix) { - - -int c = config_get_if()->argc; -int i,j; -char *pp; -char *cfgpath; + int c = config_get_if()->argc; + int i,j; + char *pp; + char cfgpath[512]; /* 512 should be enough for the sprintf below */ - j = (prefix ==NULL) ? 0 : strlen(prefix); - cfgpath = malloc( j + MAX_OPTNAME_SIZE +1); - if (cfgpath == NULL) { - fprintf(stderr,"[CONFIG] %s %i malloc error, %s\n", __FILE__, __LINE__,strerror(errno)); - return -1; - } - j = 0; i = 0; while (c > 0 ) { char *oneargv = strdup(config_get_if()->argv[i]); /* we use strtok_r which modifies its string paramater, and we don't want argv to be modified */ -/* first check help options, either --help, -h or --help_<section> */ + /* first check help options, either --help, -h or --help_<section> */ if (strncmp(oneargv, "-h",2) == 0 || strncmp(oneargv, "--help",6) == 0 ) { char *tokctx; pp=strtok_r(oneargv, "_",&tokctx); @@ -183,7 +174,7 @@ char *cfgpath; } } -/* now, check for non help options */ + /* now, check for non help options */ if (oneargv[0] == '-') { for(int n=0;n<numoptions;n++) { if ( ( cfgoptions[n].paramflags & PARAMFLAG_DISABLECMDLINE) != 0) { @@ -224,9 +215,5 @@ char *cfgpath; c--; } /* fin du while */ printf_cmdl("[CONFIG] %s %i options set from command line\n",((prefix == NULL) ? "(root)":prefix),j); - free(cfgpath); return j; } /* parse_cmdline*/ - - - diff --git a/common/config/libconfig/config_libconfig.c b/common/config/libconfig/config_libconfig.c index f192fd2dc57c0af28e5df3c72238b4b730e3c81d..cb6fa46293ed77aa97812e557f8d6c4843c10ef9 100644 --- a/common/config/libconfig/config_libconfig.c +++ b/common/config/libconfig/config_libconfig.c @@ -91,8 +91,6 @@ int read_intarray(paramdef_t *cfgoptions,config_setting_t *setting, char *cfgpat int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) { - - config_setting_t *setting; char *str; int i,u; @@ -103,15 +101,9 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) int notfound; int defval; int fatalerror=0; - char *cfgpath; /* listname.[listindex].paramname */ int numdefvals=0; - - i = (prefix ==NULL) ? 0 : strlen(prefix); - cfgpath = malloc( i+ MAX_OPTNAME_SIZE +1); - if (cfgpath == NULL) { - fprintf(stderr,"[LIBCONFIG] %s %i malloc error, %s\n", __FILE__, __LINE__,strerror(errno)); - return -1; - } + char cfgpath[512]; /* 512 should be enough for the sprintf below */ + for(i=0;i<numoptions;i++) { if (prefix != NULL) { @@ -253,7 +245,6 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) config_libconfig_end(); end_configmodule(); } - free(cfgpath); return status; }