--- libaitcfg/src/aitcfg.c 2012/04/02 14:39:02 1.4.4.1 +++ libaitcfg/src/aitcfg.c 2012/04/03 09:21:06 1.4.4.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitcfg.c,v 1.4.4.1 2012/04/02 14:39:02 misho Exp $ +* $Id: aitcfg.c,v 1.4.4.2 2012/04/03 09:21:06 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -104,6 +104,26 @@ cfg_SetErr(int eno, char *estr, ...) /* + * cfgInitConfig() - Init config root + * + * @cfg = Config root + * return: -1 error or 0 ok + */ +int +cfgInitConfig(cfg_root_t * __restrict cfg) +{ + if (!cfg) + return -1; + +#ifdef HAVE_LIBPTHREAD + pthread_mutex_init(&cfg->rc_mtx, NULL); +#endif + SLIST_INIT(cfg); + RB_INIT(cfg); + return 0; +} + +/* * cfgLoadConfig() - Load config from file * * @cfgName = Config filename @@ -119,13 +139,8 @@ cfgLoadConfig(const char *cfgName, cfg_root_t * __rest if (!cfgName || !cfg) { cfg_SetErr(EINVAL, "Invalid parameter(s)"); return -1; - } else { -#ifdef HAVE_LIBPTHREAD - pthread_mutex_init(&cfg->rc_mtx, NULL); -#endif - SLIST_INIT(cfg); - RB_INIT(cfg); - } + } else + cfgInitConfig(cfg); f = fopen(cfgName, "r"); if (!f) {