Remove non-standard __FUNCTION__ use.

This cripples the Memory API just a little bit, but I'm sure we'll still
get useful enough information.
This commit is contained in:
Jordan Bancino 2022-10-15 09:34:47 -04:00
parent 0c03c71081
commit bb93cae99a
3 changed files with 7 additions and 21 deletions

View file

@ -31,7 +31,6 @@ struct MemoryInfo
{ {
size_t size; size_t size;
const char *file; const char *file;
const char *func;
int line; int line;
void *pointer; void *pointer;
@ -45,7 +44,7 @@ static void (*hook) (MemoryAction, MemoryInfo *, void *) = NULL;
static void *hookArgs = NULL; static void *hookArgs = NULL;
void * void *
MemoryAllocate(size_t size, const char *file, int line, const char *func) MemoryAllocate(size_t size, const char *file, int line)
{ {
void *p; void *p;
MemoryInfo *a; MemoryInfo *a;
@ -70,7 +69,6 @@ MemoryAllocate(size_t size, const char *file, int line, const char *func)
a->size = size; a->size = size;
a->file = file; a->file = file;
a->line = line; a->line = line;
a->func = func;
a->pointer = p; a->pointer = p;
a->next = NULL; a->next = NULL;
a->prev = lastAllocation; a->prev = lastAllocation;
@ -261,17 +259,6 @@ MemoryInfoGetFile(MemoryInfo * a)
return a->file; return a->file;
} }
const char *
MemoryInfoGetFunc(MemoryInfo * a)
{
if (!a)
{
return NULL;
}
return a->func;
}
int int
MemoryInfoGetLine(MemoryInfo * a) MemoryInfoGetLine(MemoryInfo * a)
{ {

View file

@ -63,9 +63,9 @@ TelodendriaMemoryHook(MemoryAction a, MemoryInfo * i, void *args)
break; break;
} }
Log(lc, LOG_DEBUG, "%s:%d %s(): %s %lu bytes of memory at %p.", Log(lc, LOG_DEBUG, "%s:%d: %s %lu bytes of memory at %p.",
MemoryInfoGetFile(i), MemoryInfoGetLine(i), MemoryInfoGetFile(i), MemoryInfoGetLine(i),
MemoryInfoGetFunc(i), action, MemoryInfoGetSize(i), action, MemoryInfoGetSize(i),
MemoryInfoGetPointer(i)); MemoryInfoGetPointer(i));
} }
@ -77,8 +77,8 @@ TelodendriaMemoryIterator(MemoryInfo * i, void *args)
/* We haven't freed the logger memory yet */ /* We haven't freed the logger memory yet */
if (MemoryInfoGetPointer(i) != lc) if (MemoryInfoGetPointer(i) != lc)
{ {
Log(lc, LOG_DEBUG, "%lu bytes of memory at %p leaked from %s() (%s:%d)", Log(lc, LOG_DEBUG, "%lu bytes of memory at %p leaked from %s:%d",
MemoryInfoGetSize(i), MemoryInfoGetPointer(i), MemoryInfoGetFunc(i), MemoryInfoGetSize(i), MemoryInfoGetPointer(i),
MemoryInfoGetFile(i), MemoryInfoGetLine(i)); MemoryInfoGetFile(i), MemoryInfoGetLine(i));
} }
} }

View file

@ -33,13 +33,13 @@ typedef enum MemoryAction
MEMORY_FREE MEMORY_FREE
} MemoryAction; } MemoryAction;
#define Malloc(x) MemoryAllocate(x, __FILE__, __LINE__, __FUNCTION__) #define Malloc(x) MemoryAllocate(x, __FILE__, __LINE__)
#define Realloc(x, s) MemoryReallocate(x, s) #define Realloc(x, s) MemoryReallocate(x, s)
#define Free(x) MemoryFree(x) #define Free(x) MemoryFree(x)
typedef struct MemoryInfo MemoryInfo; typedef struct MemoryInfo MemoryInfo;
extern void *MemoryAllocate(size_t, const char *, int, const char *); extern void *MemoryAllocate(size_t, const char *, int);
extern void *MemoryReallocate(void *, size_t); extern void *MemoryReallocate(void *, size_t);
extern void MemoryFree(void *); extern void MemoryFree(void *);
@ -50,7 +50,6 @@ extern MemoryInfo *MemoryInfoGet(void *);
extern size_t MemoryInfoGetSize(MemoryInfo *); extern size_t MemoryInfoGetSize(MemoryInfo *);
extern const char *MemoryInfoGetFile(MemoryInfo *); extern const char *MemoryInfoGetFile(MemoryInfo *);
extern const char *MemoryInfoGetFunc(MemoryInfo *);
extern int MemoryInfoGetLine(MemoryInfo *); extern int MemoryInfoGetLine(MemoryInfo *);
extern void *MemoryInfoGetPointer(MemoryInfo *); extern void *MemoryInfoGetPointer(MemoryInfo *);