cutils/lib/inc/debug.h

23 lines
1.4 KiB
C
Raw Normal View History

2023-02-11 14:17:02 +01:00
#ifndef CUTILS_DEBUG_H_
#define CUTILS_DEBUG_H_
#include <stddef.h>
2023-02-11 14:40:27 +01:00
#include <stdlib.h>
#include "common.h"
2023-02-11 14:17:02 +01:00
#ifdef CUTILS_DEBUG_TRACE
2023-02-11 14:40:27 +01:00
# define malloc(size) debug_malloc (size, __FILE__, __LINE__) /* macro wrapper for debug_malloc() */
# define realloc(ptr, size) debug_realloc (ptr, size, __FILE__, __LINE__) /* macro wrapper for debug_realloc() */
# define free(ptr) debug_free (ptr, __FILE__, __LINE__) /* macro wrapper for debug_free() */
# define smalloc(size) debug_smalloc (size, __FILE__, __LINE__) /* macro wrapper for debug_malloc() */
# define srealloc(ptr, size) debug_srealloc (ptr, size, __FILE__, __LINE__) /* macro wrapper for debug_realloc() */
2023-02-11 14:17:02 +01:00
#endif
2023-02-11 14:40:27 +01:00
void *debug_malloc (size_t size, const char *file, size_t line); /* allocate memory using malloc() and print a fitting debug message */
void *debug_realloc (void *ptr, size_t size, const char *file, size_t line); /* reallocate memory using realloc() and print a fitting debug message */
void debug_free (void *ptr, const char *file, size_t line); /* free memory using free() and print a fitting debug message */
void *debug_smalloc (size_t size, const char *file, size_t line); /* allocate memory using smalloc() and print a fitting debug message */
void *debug_srealloc (void *ptr, size_t size, const char *file, size_t line); /* reallocate memory using srealloc() and print a fitting debug message */
2023-02-11 14:17:02 +01:00
#endif // CUTILS_DEBUG_H_