]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cvar.c
got rid of buildnumber.c and buildnum program, now uses builddate.c (touched each...
[xonotic/darkplaces.git] / cvar.c
diff --git a/cvar.c b/cvar.c
index bee89d929f1aeaf6b7992ed7ac190cbbd846d9f1..25ad1421f93ea6526602fec2aa57f14b50d398dd 100644 (file)
--- a/cvar.c
+++ b/cvar.c
@@ -172,10 +172,17 @@ void Cvar_Set (char *var_name, char *value)
        }
 
        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;