aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/config.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/main/config.c b/main/config.c
index 21a569dfc..7d2af29c6 100644
--- a/main/config.c
+++ b/main/config.c
@@ -183,6 +183,8 @@ struct ast_config {
int max_include_level;
};
+static void ast_destroy_comment(struct ast_comment **comment);
+
struct ast_variable *ast_variable_new(const char *name, const char *value)
{
struct ast_variable *variable;
@@ -218,6 +220,8 @@ void ast_variables_destroy(struct ast_variable *v)
while(v) {
vn = v;
v = v->next;
+ ast_destroy_comment(&vn->precomments);
+ ast_destroy_comment(&vn->sameline);
free(vn);
}
}
@@ -344,19 +348,22 @@ void ast_category_append(struct ast_config *config, struct ast_category *categor
config->current = category;
}
-static void ast_destroy_comments(struct ast_category *cat)
+static void ast_destroy_comment(struct ast_comment **comment)
{
struct ast_comment *n, *p;
- for (p=cat->precomments; p; p=n) {
- n = p->next;
- free(p);
- }
- for (p=cat->sameline; p; p=n) {
+
+ for (p = *comment; p; p = n) {
n = p->next;
free(p);
}
- cat->precomments = NULL;
- cat->sameline = NULL;
+
+ *comment = NULL;
+}
+
+static void ast_destroy_comments(struct ast_category *cat)
+{
+ ast_destroy_comment(&cat->precomments);
+ ast_destroy_comment(&cat->sameline);
}
static void ast_destroy_template_list(struct ast_category *cat)