DebugMemory.h 1.28 KB
Newer Older
Hisham Muhammad's avatar
Hisham Muhammad committed
1
/* Do not edit this file. It was automatically generated. */
Hisham Muhammad's avatar
Hisham Muhammad committed
2
3
4
5
6

#ifndef HEADER_DebugMemory
#define HEADER_DebugMemory

#define _GNU_SOURCE
Hisham Muhammad's avatar
Hisham Muhammad committed
7
#include <string.h>
Hisham Muhammad's avatar
Hisham Muhammad committed
8
9
10
11
12
13
14
15
16
17
18
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <assert.h>

#undef strdup
#undef malloc
#undef realloc
#undef calloc
#undef free

Hisham Muhammad's avatar
Hisham Muhammad committed
19
20


Hisham Muhammad's avatar
Hisham Muhammad committed
21
22
23
typedef struct DebugMemoryItem_ DebugMemoryItem;

struct DebugMemoryItem_ {
Hisham Muhammad's avatar
Hisham Muhammad committed
24
   int magic;
Hisham Muhammad's avatar
Hisham Muhammad committed
25
26
27
28
29
30
31
32
33
34
35
   void* data;
   char* file;
   int line;
   DebugMemoryItem* next;
};

typedef struct DebugMemory_ {
   DebugMemoryItem* first;
   int allocations;
   int deallocations;
   int size;
Hisham Muhammad's avatar
Hisham Muhammad committed
36
   bool totals;
Hisham Muhammad's avatar
Hisham Muhammad committed
37
38
39
40
   FILE* file;
} DebugMemory;


Hisham Muhammad's avatar
Hisham Muhammad committed
41
42
#if defined(DEBUG)

Hisham Muhammad's avatar
Hisham Muhammad committed
43
44
void DebugMemory_new();

Hisham Muhammad's avatar
Hisham Muhammad committed
45
void* DebugMemory_malloc(int size, char* file, int line, char* str);
Hisham Muhammad's avatar
Hisham Muhammad committed
46
47
48

void* DebugMemory_calloc(int a, int b, char* file, int line);

Hisham Muhammad's avatar
Hisham Muhammad committed
49
void* DebugMemory_realloc(void* ptr, int size, char* file, int line, char* str);
Hisham Muhammad's avatar
Hisham Muhammad committed
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

void* DebugMemory_strdup(char* str, char* file, int line);

void DebugMemory_free(void* data, char* file, int line);

void DebugMemory_assertSize();

int DebugMemory_getBlockCount();

void DebugMemory_registerAllocation(void* data, char* file, int line);

void DebugMemory_registerDeallocation(void* data, char* file, int line);

void DebugMemory_report();

Hisham Muhammad's avatar
Hisham Muhammad committed
65
66
67
68
69
70
#elif defined(DEBUGLITE)

//#include "efence.h"

#endif

Hisham Muhammad's avatar
Hisham Muhammad committed
71
#endif