From: Wolfgang Bumiller Date: Mon, 15 Apr 2013 18:53:53 +0000 (+0200) Subject: util_strdup: don't use util_memory_a with -DNOTRACK X-Git-Tag: before-library~61 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1caf1b3ebef2b73e5440412e6c5964ac592ae129;p=xonotic%2Fgmqcc.git util_strdup: don't use util_memory_a with -DNOTRACK --- diff --git a/gmqcc.h b/gmqcc.h index 223e0d7..2b2fca0 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -317,13 +317,15 @@ int util_asprintf (char **ret, const char *fmt, ...); #ifdef NOTRACK -# define mem_a(x) malloc (x) -# define mem_d(x) free ((void*)x) -# define mem_r(x, n) realloc((void*)x, n) +# define mem_a(x) malloc (x) +# define mem_d(x) free ((void*)x) +# define mem_r(x, n) realloc((void*)x, n) +# define mem_af(x,f,l) malloc (x) #else -# define mem_a(x) util_memory_a((x), __LINE__, __FILE__) -# define mem_d(x) util_memory_d((void*)(x)) -# define mem_r(x, n) util_memory_r((void*)(x), (n), __LINE__, __FILE__) +# define mem_a(x) util_memory_a((x), __LINE__, __FILE__) +# define mem_d(x) util_memory_d((void*)(x)) +# define mem_r(x, n) util_memory_r((void*)(x), (n), __LINE__, __FILE__) +# define mem_af(x) util_memory_a((x), __LINE__, __FILE__) #endif /*! NOTRACK */ #define util_strdup(X) _util_Estrdup((X), __FILE__, __LINE__) diff --git a/util.c b/util.c index 2e2aec3..c692760 100644 --- a/util.c +++ b/util.c @@ -163,10 +163,14 @@ char *_util_Estrdup(const char *s, const char *file, size_t line) { size_t len = 0; char *ptr = NULL; + /* in case of -DNOTRACK */ + (void)file; + (void)line; + if (!s) return NULL; - if ((len = strlen(s)) && (ptr = (char*)util_memory_a(len+1, line, file))) { + if ((len = strlen(s)) && (ptr = (char*)mem_af(len+1, line, file))) { memcpy(ptr, s, len); ptr[len] = '\0'; }