diff options
author | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-24 00:56:56 +0200 |
---|---|---|
committer | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-24 00:56:56 +0200 |
commit | f2a4f0412bc1f7b9069ecbcce8f5599f46f757e0 (patch) | |
tree | 4433480af957dbc48a805cc1d94ad897d11c7395 /common/eurephia_nullsafe.c | |
parent | 1a64e64694faba6783b1d05a193019f1ec241645 (diff) | |
download | eurephia-f2a4f0412bc1f7b9069ecbcce8f5599f46f757e0.tar.gz eurephia-f2a4f0412bc1f7b9069ecbcce8f5599f46f757e0.tar.xz eurephia-f2a4f0412bc1f7b9069ecbcce8f5599f46f757e0.zip |
Improved file logging, providing source file and line number info
Also changed malloc_nullsafe() and free_nullsafe() to report directly
which file:line which called the malloc/free function.
Diffstat (limited to 'common/eurephia_nullsafe.c')
-rw-r--r-- | common/eurephia_nullsafe.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/common/eurephia_nullsafe.c b/common/eurephia_nullsafe.c index bd78d6b..f70b463 100644 --- a/common/eurephia_nullsafe.c +++ b/common/eurephia_nullsafe.c @@ -65,10 +65,15 @@ void *__malloc_nullsafe(eurephiaCTX *ctx, size_t sz, const char *file, int line) "Could not allocate memory region for %ld bytes (File %s, line %i)", sz, file, line); } - } else { - DEBUG(ctx, 40, "Allocated %ld bytes of memory on address %p (File %s, line %i)", - sz, buf, file, line); } +#ifdef DEBUG + else { + // Don't use DEBUG macro, to catch the right file and line number for the log + _eurephia_log_func(ctx, LOG_DEBUG, 40, file, line, + "Allocated %ld bytes of memory on address %p", + sz, buf); + } +#endif return buf; } @@ -87,6 +92,9 @@ void inline __free_nullsafe(eurephiaCTX *ctx, void *ptr, const char *file, int l if( ptr == NULL ) { return; } - DEBUG(ctx, 40, "Freeing memory on address %p (File %s, line %i)", ptr, file, line); +#ifdef DEBUG + // Don't use DEBUG macro, to catch the right file and line number for the log + _eurephia_log_func(ctx, LOG_DEBUG, 40, file, line, "Freeing memory on address %p", ptr); +#endif free(ptr); } |