aboutsummaryrefslogtreecommitdiffstats
path: root/code
diff options
context:
space:
mode:
Diffstat (limited to 'code')
-rw-r--r--code/botlib/l_libvar.c5
-rw-r--r--code/botlib/l_precomp.c13
2 files changed, 10 insertions, 8 deletions
diff --git a/code/botlib/l_libvar.c b/code/botlib/l_libvar.c
index 4277544..0270781 100644
--- a/code/botlib/l_libvar.c
+++ b/code/botlib/l_libvar.c
@@ -84,9 +84,9 @@ libvar_t *LibVarAlloc(char *var_name)
{
libvar_t *v;
- v = (libvar_t *) GetMemory(sizeof(libvar_t) + strlen(var_name) + 1);
+ v = (libvar_t *) GetMemory(sizeof(libvar_t));
Com_Memset(v, 0, sizeof(libvar_t));
- v->name = (char *) v + sizeof(libvar_t);
+ v->name = (char *) GetMemory(strlen(var_name)+1);
strcpy(v->name, var_name);
//add the variable in the list
v->next = libvarlist;
@@ -102,6 +102,7 @@ libvar_t *LibVarAlloc(char *var_name)
void LibVarDeAlloc(libvar_t *v)
{
if (v->string) FreeMemory(v->string);
+ FreeMemory(v->name);
FreeMemory(v);
} //end of the function LibVarDeAlloc
//===========================================================================
diff --git a/code/botlib/l_precomp.c b/code/botlib/l_precomp.c
index 8b5e4d3..866a601 100644
--- a/code/botlib/l_precomp.c
+++ b/code/botlib/l_precomp.c
@@ -653,6 +653,7 @@ void PC_FreeDefine(define_t *define)
PC_FreeToken(t);
} //end for
//free the define
+ FreeMemory(define->name);
FreeMemory(define);
} //end of the function PC_FreeDefine
//============================================================================
@@ -680,9 +681,9 @@ void PC_AddBuiltinDefines(source_t *source)
for (i = 0; builtin[i].string; i++)
{
- define = (define_t *) GetMemory(sizeof(define_t) + strlen(builtin[i].string) + 1);
+ define = (define_t *) GetMemory(sizeof(define_t));
Com_Memset(define, 0, sizeof(define_t));
- define->name = (char *) define + sizeof(define_t);
+ define->name = (char *) GetMemory(strlen(builtin[i].string) + 1);
strcpy(define->name, builtin[i].string);
define->flags |= DEFINE_FIXED;
define->builtin = builtin[i].builtin;
@@ -1216,9 +1217,9 @@ int PC_Directive_define(source_t *source)
#endif //DEFINEHASHING
} //end if
//allocate define
- define = (define_t *) GetMemory(sizeof(define_t) + strlen(token.string) + 1);
+ define = (define_t *) GetMemory(sizeof(define_t));
Com_Memset(define, 0, sizeof(define_t));
- define->name = (char *) define + sizeof(define_t);
+ define->name = (char *) GetMemory(strlen(token.string) + 1);
strcpy(define->name, token.string);
//add the define to the source
#if DEFINEHASHING
@@ -1452,9 +1453,9 @@ define_t *PC_CopyDefine(source_t *source, define_t *define)
define_t *newdefine;
token_t *token, *newtoken, *lasttoken;
- newdefine = (define_t *) GetMemory(sizeof(define_t) + strlen(define->name) + 1);
+ newdefine = (define_t *) GetMemory(sizeof(define_t));
//copy the define name
- newdefine->name = (char *) newdefine + sizeof(define_t);
+ newdefine->name = (char *) GetMemory(strlen(define->name) + 1);
strcpy(newdefine->name, define->name);
newdefine->flags = define->flags;
newdefine->builtin = define->builtin;