mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-10 06:49:40 +00:00
channels: Allow updating variable value
When modifying an already defined variable in some channel drivers they add a new variable with the same name to the list, but that value is never used, only the first one found. Introduce ast_variable_list_replace() and use it where appropriate. ASTERISK-23756 #close Patches: setvar-multiplie.patch submitted by Michael Goryainov Change-Id: Ie1897a96c82b8945e752733612ee963686f32839
This commit is contained in:
@@ -665,6 +665,22 @@ struct ast_variable *ast_variable_list_append_hint(struct ast_variable **head, s
|
||||
return curr;
|
||||
}
|
||||
|
||||
int ast_variable_list_replace(struct ast_variable **head, struct ast_variable *replacement)
|
||||
{
|
||||
struct ast_variable *v, **prev = head;
|
||||
|
||||
for (v = *head; v; prev = &v->next, v = v->next) {
|
||||
if (!strcmp(v->name, replacement->name)) {
|
||||
replacement->next = v->next;
|
||||
*prev = replacement;
|
||||
ast_free(v);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char *ast_config_option(struct ast_config *cfg, const char *cat, const char *var)
|
||||
{
|
||||
const char *tmp;
|
||||
|
Reference in New Issue
Block a user