mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-19 06:40:49 +00:00
util_strdup: don't use util_memory_a with -DNOTRACK
This commit is contained in:
parent
c2b5a95961
commit
1caf1b3ebe
2 changed files with 13 additions and 7 deletions
14
gmqcc.h
14
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__)
|
||||
|
|
6
util.c
6
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';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue