switch (type) {
case MISDN_CTYPE_STR:
+ if (dest->str) {
+ ast_free(dest->str);
+ }
if ((len = strlen(value))) {
dest->str = ast_malloc((len + 1) * sizeof(char));
strncpy(dest->str, value, len);
res = sscanf(value, "%30d", &tmp);
}
if (res) {
- dest->num = ast_malloc(sizeof(int));
+ if (!dest->num) {
+ dest->num = ast_malloc(sizeof(int));
+ }
memcpy(dest->num, &tmp, sizeof(int));
} else
re = -1;
}
break;
case MISDN_CTYPE_BOOL:
- dest->num = ast_malloc(sizeof(int));
+ if (!dest->num) {
+ dest->num = ast_malloc(sizeof(int));
+ }
*(dest->num) = (ast_true(value) ? 1 : 0);
break;
case MISDN_CTYPE_BOOLINT:
- dest->num = ast_malloc(sizeof(int));
+ if (!dest->num) {
+ dest->num = ast_malloc(sizeof(int));
+ }
if (sscanf(value, "%30d", &tmp)) {
memcpy(dest->num, &tmp, sizeof(int));
} else {
}
break;
case MISDN_CTYPE_ASTGROUP:
- dest->grp = ast_malloc(sizeof(ast_group_t));
+ if (!dest->grp) {
+ dest->grp = ast_malloc(sizeof(ast_group_t));
+ }
*(dest->grp) = ast_get_group(value);
break;
}