char **buf;
len = strlen(partial);
- buf = qmalloc(sizeofbuf + sizeof (char *));
+ buf = Mem_Alloc(tempmempool, sizeofbuf + sizeof (char *));
// Loop through the alias list and print all matches
for (cvar = cvar_vars; cvar; cvar = cvar->next)
if (!strncasecmp(partial, cvar->name, len))
}
changed = strcmp(var->string, value);
+ // LordHavoc: don't reallocate when there is no change
+ if (!changed)
+ return;
- Z_Free (var->string); // free the old value string
+ // LordHavoc: don't reallocate when the buffer is the same size
+ if (!var->string || strlen(var->string) != strlen(value))
+ {
+ Z_Free (var->string); // free the old value string
- var->string = Z_Malloc (strlen(value)+1);
+ var->string = Z_Malloc (strlen(value)+1);
+ }
strcpy (var->string, value);
var->value = atof (var->string);
+ var->integer = (int) var->value;
if ((var->flags & CVAR_NOTIFY) && changed)
{
if (sv.active)
variable->string = Z_Malloc (strlen(variable->string)+1);
strcpy (variable->string, oldstr);
variable->value = atof (variable->string);
+ variable->integer = (int) variable->value;
// link the variable in
variable->next = cvar_vars;