Moved to realloc instead of always allocating new memory.
This commit is contained in:
@ -175,15 +175,14 @@ CONFIG_PARAMETER *param, *p1;
|
|||||||
if (!strcmp(p1->name, name))
|
if (!strcmp(p1->name, name))
|
||||||
{
|
{
|
||||||
char* tmp;
|
char* tmp;
|
||||||
|
int paramlen = strlen(p1->value) + strlen(value) + 2;
|
||||||
|
|
||||||
if((tmp = malloc(sizeof(char) * (strlen(p1->value) + strlen(value) + 2))) == NULL)
|
if((tmp = realloc(p1->value,sizeof(char) * (paramlen))) == NULL)
|
||||||
{
|
{
|
||||||
skygw_log_write(LE,"[%s] Error: Memory allocation failed.",__FUNCTION__);
|
skygw_log_write(LE,"[%s] Error: Memory allocation failed.",__FUNCTION__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
strcpy(tmp,p1->value);
|
|
||||||
strcat(tmp,value);
|
strcat(tmp,value);
|
||||||
free(p1->value);
|
|
||||||
p1->value = tmp;
|
p1->value = tmp;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user