diff options
Diffstat (limited to 'src/pacman/conf.c')
-rw-r--r-- | src/pacman/conf.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/pacman/conf.c b/src/pacman/conf.c index 245e3c04..2bc69820 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -23,32 +23,36 @@ #include <stdlib.h> #include <stdio.h> +#include <string.h> /* strdup */ /* pacman */ #include "conf.h" config_t *config_new(void) { - config_t *config = calloc(1, sizeof(config_t)); - if(!config) { + config_t *newconfig = calloc(1, sizeof(config_t)); + if(!newconfig) { fprintf(stderr, "malloc failure: could not allocate %d bytes\n", sizeof(config_t)); } - config->op = PM_OP_MAIN; - config->logmask = PM_LOG_ERROR | PM_LOG_WARNING; + /* defaults which may get overridden later */ + newconfig->op = PM_OP_MAIN; + newconfig->logmask = PM_LOG_ERROR | PM_LOG_WARNING; + /* CONFFILE is defined at compile-time */ + newconfig->configfile = strdup(CONFFILE); - return(config); + return(newconfig); } -int config_free(config_t *config) +int config_free(config_t *oldconfig) { - if(config == NULL) { + if(oldconfig == NULL) { return(-1); } - free(config->configfile); - free(config); - config = NULL; + free(oldconfig->configfile); + free(oldconfig); + oldconfig = NULL; return(0); } |