RAVE
rave_alloc.h
Go to the documentation of this file.
1
7#ifndef RAVE_ALLOC_H
8#define RAVE_ALLOC_H
9#include <stdlib.h>
10
18void* rave_alloc_malloc(const char* filename, int lineno, size_t sz);
19
27void* rave_alloc_calloc(const char* filename, int lineno, size_t npts, size_t sz);
28
36void* rave_alloc_realloc(const char* filename, int lineno, void* ptr, size_t sz);
37
44char* rave_alloc_strdup(const char* filename, int lineno, const char* str);
45
52void rave_alloc_free(const char* filename, int lineno, void* ptr);
53
57void rave_alloc_dump_heap(void);
58
63
64#ifdef RAVE_MEMORY_DEBUG
68#define RAVE_MALLOC(sz) rave_alloc_malloc(__FILE__, __LINE__, sz)
69
73#define RAVE_CALLOC(npts,sz) rave_alloc_calloc(__FILE__, __LINE__, npts, sz)
74
78#define RAVE_REALLOC(ptr, sz) rave_alloc_realloc(__FILE__, __LINE__, ptr, sz)
79
83#define RAVE_STRDUP(x) rave_alloc_strdup(__FILE__, __LINE__, x)
84
88#define RAVE_FREE(x) if (x != NULL) {rave_alloc_free(__FILE__, __LINE__, x); x=NULL;}
89
90#else
94#define RAVE_MALLOC(sz) malloc(sz)
95
99#define RAVE_CALLOC(npts,sz) calloc(npts, sz)
100
104#define RAVE_REALLOC(ptr, sz) realloc(ptr, sz)
105
109#define RAVE_STRDUP(x) strdup(x)
110
114#define RAVE_FREE(x) if (x != NULL) {free(x);x=NULL;}
115
116#endif
117
118
119#endif /* RAVE_ALLOC_H */
char * rave_alloc_strdup(const char *filename, int lineno, const char *str)
Same as strdup but debugged.
Definition rave_alloc.c:264
void rave_alloc_free(const char *filename, int lineno, void *ptr)
Releases the memory.
Definition rave_alloc.c:291
void rave_alloc_print_statistics(void)
Prints the statistics for the heap.
Definition rave_alloc.c:336
void rave_alloc_dump_heap(void)
Dumps all blocks that not has been released.
Definition rave_alloc.c:317
void * rave_alloc_calloc(const char *filename, int lineno, size_t npts, size_t sz)
Same as calloc but debugged.
Definition rave_alloc.c:216
void * rave_alloc_realloc(const char *filename, int lineno, void *ptr, size_t sz)
Same as realloc but debugged.
Definition rave_alloc.c:236
void * rave_alloc_malloc(const char *filename, int lineno, size_t sz)
Allocates memory and keeps track on if it is released, overwritten and similar.
Definition rave_alloc.c:202