[Asterisk-cvs] asterisk config.c,1.53,1.54
markster at lists.digium.com
markster at lists.digium.com
Sun Jan 30 11:33:13 CST 2005
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv11131
Modified Files:
config.c
Log Message:
Fix seg in variable replacement (bug #3464)
Index: config.c
===================================================================
RCS file: /usr/cvsroot/asterisk/config.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- config.c 30 Jan 2005 06:26:19 -0000 1.53
+++ config.c 30 Jan 2005 17:34:44 -0000 1.54
@@ -124,59 +124,13 @@
return variable;
}
-static struct ast_variable *variable_get(const struct ast_category *category, const char *name)
-{
- struct ast_variable *variable;
-
- for (variable = category->root; variable; variable = variable->next)
- if (!strcasecmp(variable->name, name))
- return variable;
-
- return NULL;
-}
-
-static void variable_remove(struct ast_category *category, const struct ast_variable *variable)
-{
- struct ast_variable *prev = category->root;
-
- if (!prev)
- return;
-
- if (prev == variable) {
- category->root = prev->next;
- if (category->last == variable)
- category->last = NULL;
- } else {
- while (prev->next && (prev->next != variable)) prev = prev->next;
- if (prev->next) {
- prev->next = variable->next;
- if (category->last == variable)
- category->last = prev;
- }
- }
-}
-
void ast_variable_append(struct ast_category *category, struct ast_variable *variable)
{
- /* Note: this function also implements "variable replacement"... if the
- new variable's value is empty, then existing variables of the same
- name in the category are removed (and the new variable is destroyed)
- */
- if (variable->value && !ast_strlen_zero(variable->value)) {
- if (category->last)
- category->last->next = variable;
- else
- category->root = variable;
- category->last = variable;
- } else {
- struct ast_variable *v;
-
- while ((v = variable_get(category, variable->name))) {
- variable_remove(category, v);
- ast_variables_destroy(v);
- }
- ast_variables_destroy(variable);
- }
+ if (category->last)
+ category->last->next = variable;
+ else
+ category->root = variable;
+ category->last = variable;
}
void ast_variables_destroy(struct ast_variable *v)
More information about the svn-commits
mailing list