]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
zone: Pass __FILE__ and __LINE__ to Mem_strdup
authorCloudwalk <cloudwalk009@gmail.com>
Tue, 20 Jul 2021 18:10:02 +0000 (14:10 -0400)
committerCloudwalk <cloudwalk009@gmail.com>
Tue, 20 Jul 2021 18:10:02 +0000 (14:10 -0400)
Made it a macro for _Mem_strdup which is what Mem_strdup was.
We have to call _Mem_Alloc directly to pass __FILE__ and __LINE__
to that function.

zone.c
zone.h

diff --git a/zone.c b/zone.c
index 60598cd8ab2a8895f683311b26c568264a3026d1..23258a278c0bcc74b90323f353856bcd265ed662 100644 (file)
--- a/zone.c
+++ b/zone.c
@@ -871,14 +871,14 @@ static void MemStats_f(cmd_state_t *cmd)
 }
 
 
-char* Mem_strdup (mempool_t *pool, const char* s)
+char* _Mem_strdup (mempool_t *pool, const char* s, const char *filename, int fileline)
 {
        char* p;
        size_t sz;
        if (s == NULL)
                return NULL;
        sz = strlen (s) + 1;
-       p = (char*)Mem_Alloc (pool, sz);
+       p = (char*)_Mem_Alloc (pool, NULL, sz, 16, filename, fileline);
        strlcpy (p, s, sz);
        return p;
 }
diff --git a/zone.h b/zone.h
index a78372267114d9a61836774fd566914b674c3d6e..46b2d1df1125a51ee03375eb2d42bfafd46280bd 100644 (file)
--- a/zone.h
+++ b/zone.h
@@ -86,6 +86,7 @@ mempool_t;
 #define Mem_Memalign(pool,alignment,size) _Mem_Alloc(pool, NULL, size, alignment, __FILE__, __LINE__)
 #define Mem_Realloc(pool,data,size) _Mem_Alloc(pool, data, size, 16, __FILE__, __LINE__)
 #define Mem_Free(mem) _Mem_Free(mem, __FILE__, __LINE__)
+#define Mem_strdup(pool, s) _Mem_strdup(pool, s, __FILE__, __LINE__)
 #define Mem_CheckSentinels(data) _Mem_CheckSentinels(data, __FILE__, __LINE__)
 #if MEMPARANOIA
 #define Mem_CheckSentinelsGlobal()  _Mem_CheckSentinelsGlobal(__FILE__, __LINE__)
@@ -106,7 +107,7 @@ void _Mem_CheckSentinelsGlobal(const char *filename, int fileline);
 // if pool is NULL this searches ALL pools for the allocation
 qbool Mem_IsAllocated(mempool_t *pool, void *data);
 
-char* Mem_strdup (mempool_t *pool, const char* s);
+char* _Mem_strdup (mempool_t *pool, const char* s, const char *filename, int fileline);
 
 typedef struct memexpandablearray_array_s
 {