From: Cloudwalk Date: Tue, 20 Jul 2021 18:10:02 +0000 (-0400) Subject: zone: Pass __FILE__ and __LINE__ to Mem_strdup X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1d09c69f77366f89addbf1cc72b4ed87f9ce5931;p=xonotic%2Fdarkplaces.git zone: Pass __FILE__ and __LINE__ to Mem_strdup 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. --- diff --git a/zone.c b/zone.c index 60598cd8..23258a27 100644 --- 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 a7837226..46b2d1df 100644 --- 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 {