Diff for /libaitcfg/src/aitcfg.c between versions 1.16.6.3 and 1.16.6.4

version 1.16.6.3, 2025/08/19 11:22:09 version 1.16.6.4, 2025/08/19 11:40:13
Line 160  cfgEndConfig(cfg_root_t **pcfg) Line 160  cfgEndConfig(cfg_root_t **pcfg)
  * cfgInitConfigExt() - Init existed config root   * cfgInitConfigExt() - Init existed config root
  *   *
  * @cfg = Config root   * @cfg = Config root
 * return: NULL error or !=NULL inited config root * return: -1 error or 0 inited config root
  */   */
cfg_root_t *int
 cfgInitConfigExt(cfg_root_t * __restrict cfg)  cfgInitConfigExt(cfg_root_t * __restrict cfg)
 {  {
        pthread_mutex_t mtx = { 0 };        if (!cfg) {
                 cfg_SetErr(EINVAL, "Invalid parameter");
                 return -1;
         }
   
         if (!TAILQ_EMPTY(cfg) || !RB_EMPTY(cfg) ||  
                         memcmp(&cfg->rc_mtx, &mtx, sizeof mtx))  
                 cfgUnloadConfig(cfg);  
   
         memset(cfg, 0, sizeof(cfg_root_t));          memset(cfg, 0, sizeof(cfg_root_t));
   
         pthread_mutex_init(&cfg->rc_mtx, NULL);          pthread_mutex_init(&cfg->rc_mtx, NULL);
   
         TAILQ_INIT(cfg);          TAILQ_INIT(cfg);
         RB_INIT(cfg);          RB_INIT(cfg);
        return cfg;        return 0;
 }  }
   
 /*  /*
Line 192  cfgLoadConfig(const char *cfgName, cfg_root_t * __rest Line 191  cfgLoadConfig(const char *cfgName, cfg_root_t * __rest
 {  {
         FILE *f;          FILE *f;
         int ret;          int ret;
         pthread_mutex_t mtx = { 0 };  
   
        if (!cfgName || !cfg) {        if (!cfgName || cfgInitConfigExt(cfg)) {
                 cfg_SetErr(EINVAL, "Invalid parameter(s)");                  cfg_SetErr(EINVAL, "Invalid parameter(s)");
                 return -1;                  return -1;
         } else {  
                 if (!TAILQ_EMPTY(cfg) || !RB_EMPTY(cfg) || memcmp(&cfg->rc_mtx, &mtx, sizeof mtx))  
                         cfgUnloadConfig(cfg);  
                 /*  
                 if (memcmp(&cfg->rc_mtx, &mtx, sizeof mtx))  
                         pthread_mutex_destroy(&cfg->rc_mtx);  
                         */  
   
                 memset(cfg, 0, sizeof(cfg_root_t));  
   
                 pthread_mutex_init(&cfg->rc_mtx, NULL);  
   
                 TAILQ_INIT(cfg);  
                 RB_INIT(cfg);  
         }          }
   
         f = fopen(cfgName, "r");          f = fopen(cfgName, "r");

Removed from v.1.16.6.3  
changed lines
  Added in v.1.16.6.4


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>