Add a massive set of changes for converting to use the ast_debug() macro.
[asterisk/asterisk.git] / main / config.c
index 50979b4..ad71384 100644 (file)
@@ -140,7 +140,8 @@ static void CB_RESET(char **comment_buffer, char **lline_buffer)
 
 static struct ast_comment *ALLOC_COMMENT(const char *buffer)
 { 
-       struct ast_comment *x = ast_calloc(1,sizeof(struct ast_comment)+strlen(buffer)+1);
+       struct ast_comment *x;
+       x = ast_calloc(1, sizeof(*x)+strlen(buffer)+1);
        strcpy(x->cmt, buffer);
        return x;
 }
@@ -215,7 +216,7 @@ void ast_variables_destroy(struct ast_variable *v)
        while (v) {
                vn = v;
                v = v->next;
-               free(vn);
+               ast_free(vn);
        }
 }
 
@@ -344,7 +345,7 @@ void ast_category_append(struct ast_config *config, struct ast_category *categor
 void ast_category_destroy(struct ast_category *cat)
 {
        ast_variables_destroy(cat->root);
-       free(cat);
+       ast_free(cat);
 }
 
 static struct ast_category *next_available_category(struct ast_category *cat)
@@ -522,7 +523,7 @@ int ast_category_delete(struct ast_config *cfg, const char *category)
                                if (cat == cfg->last)
                                        cfg->last = NULL;
                        }
-                       free(cat);
+                       ast_free(cat);
                        return 0;
                }
                prev = cat;
@@ -543,7 +544,7 @@ int ast_category_delete(struct ast_config *cfg, const char *category)
                                if (cat == cfg->last)
                                        cfg->last = NULL;
                        }
-                       free(cat);
+                       ast_free(cat);
                        return 0;
                }
                prev = cat;
@@ -564,9 +565,9 @@ void ast_config_destroy(struct ast_config *cfg)
                ast_variables_destroy(cat->root);
                catn = cat;
                cat = cat->next;
-               free(catn);
+               ast_free(catn);
        }
-       free(cfg);
+       ast_free(cfg);
 }
 
 struct ast_category *ast_config_get_current_category(const struct ast_config *cfg)
@@ -828,15 +829,13 @@ static struct ast_config *config_text_file_load(const char *database, const char
                        fflush(stdout);
                }
                if (!(f = fopen(fn, "r"))) {
-                       if (option_debug)
-                               ast_log(LOG_DEBUG, "No file to parse: %s\n", fn);
+                       ast_debug(1, "No file to parse: %s\n", fn);
                        if (option_verbose > 1)
                                ast_verbose( "Not found (%s)\n", strerror(errno));
                        continue;
                }
                count++;
-               if (option_debug)
-                       ast_log(LOG_DEBUG, "Parsing %s\n", fn);
+               ast_debug(1, "Parsing %s\n", fn);
                if (option_verbose > 1)
                        ast_verbose("Found\n");
                while (!feof(f)) {
@@ -934,8 +933,8 @@ static struct ast_config *config_text_file_load(const char *database, const char
 #endif
 
        if (cfg && cfg->include_level == 1 && withcomments && comment_buffer) {
-               free(comment_buffer);
-               free(lline_buffer);
+               ast_free(comment_buffer);
+               ast_free(lline_buffer);
                comment_buffer = NULL;
                lline_buffer = NULL;
                comment_buffer_size = 0;
@@ -1027,8 +1026,7 @@ int config_text_file_save(const char *configfile, const struct ast_config *cfg,
                if ((option_verbose > 1) && !option_debug)
                        ast_verbose("Saved\n");
        } else {
-               if (option_debug)
-                       ast_log(LOG_DEBUG, "Unable to open for writing: %s\n", fn);
+               ast_debug(1, "Unable to open for writing: %s\n", fn);
                if (option_verbose > 1)
                        ast_verbose(VERBOSE_PREFIX_2 "Unable to write (%s)", strerror(errno));
                return -1;
@@ -1046,7 +1044,7 @@ static void clear_config_maps(void)
        while (config_maps) {
                map = config_maps;
                config_maps = config_maps->next;
-               free(map);
+               ast_free(map);
        }
                
        ast_mutex_unlock(&config_lock);
@@ -1345,7 +1343,7 @@ struct ast_variable *ast_load_realtime(const char *family, ...)
        /* Eliminate blank entries */
        for (cur = res; cur; cur = cur->next) {
                if (freeme) {
-                       free(freeme);
+                       ast_free(freeme);
                        freeme = NULL;
                }