30 #error "Are you including freeform.h? -- a compiler type must be set!"
33 #define MEMTRACK_LOG "memtrack.log"
35 #define MEMTRACK_OFF 0
36 #define MEMTRACK_BASIC 1
37 #define MEMTRACK_TRACE 2
38 #define MEMTRACK_ULTRA 3
62 #define NO_TAG "generic tag"
65 #define ROUTINE_NAME "unfilled () name"
68 #ifdef FIND_UNWRAPPED_MEM
70 #define MEMTRACK MEMTRACK_ULTRA
73 #define calloc I_should_be_memCalloc
74 #define free I_should_be_memFree
75 #define malloc I_should_be_memMalloc
76 #define realloc I_should_be_memRealloc
77 #define strdup I_should_be_memStrdup
79 #if MEMTRACK == MEMTRACK_ULTRA
81 #define strcpy I_should_be_memStrcpy
82 #define strncpy I_should_be_memStrncpy
83 #define strcat I_should_be_memStrcat
84 #define strncat I_should_be_memStrncat
85 #define strcmp I_should_be_memStrcmp
86 #define strncmp I_should_be_memStrncmp
87 #define strchr I_should_be_memStrchr
88 #define strrchr I_should_be_memStrrchr
89 #define strstr I_should_be_memStrstr
90 #define memcpy I_should_be_memMemcpy
91 #define memmove I_should_be_memMemmove
92 #define memset I_should_be_memMemset
98 #if MEMTRACK >= MEMTRACK_BASIC
102 #define memCalloc(NOBJ, SIZE, TAG) MEMCalloc(NOBJ, SIZE)
103 #define memFree(P, TAG) MEMFree(P)
104 #define memMalloc(SIZE, TAG) MEMMalloc(SIZE)
105 #define memRealloc(P, SIZE, TAG) MEMRealloc(P, SIZE)
106 #define memStrdup(STRING, TAG) MEMStrdup(STRING)
107 #define memExit(STATUS, TAG) MEMExit(STATUS)
109 void *MEMCalloc(
size_t nobj,
size_t size);
110 void MEMFree(
void *p);
111 void *MEMMalloc(
size_t size);
112 void *MEMRealloc(
void *p,
size_t size);
113 char *MEMStrdup(
const char *
string);
114 void MEMExit(
int status);
118 #define memCalloc(NOBJ, SIZE, TAG) MEMCalloc(NOBJ, SIZE, TAG, ROUTINE_NAME, __FILE__, __LINE__)
119 #define memFree(P, TAG) MEMFree(P, TAG, ROUTINE_NAME, __FILE__, __LINE__)
120 #define memMalloc(SIZE, TAG) MEMMalloc(SIZE, TAG, ROUTINE_NAME, __FILE__, __LINE__)
121 #define memRealloc(P, SIZE, TAG) MEMRealloc(P, SIZE, TAG, ROUTINE_NAME, __FILE__, __LINE__)
122 #define memStrdup(STRING, TAG) MEMStrdup(STRING, TAG, ROUTINE_NAME, __FILE__, __LINE__)
123 #define memExit(STATUS, TAG) MEMExit(STATUS, TAG, ROUTINE_NAME, __FILE__, __LINE__)
125 void *MEMCalloc(
size_t nobj,
size_t size,
char *tag,
char *routine_name,
char *cfile_name,
int line_number);
126 void MEMFree(
void *p,
char *tag,
char *routine_name,
char *cfile_name,
int line_number);
127 void *MEMMalloc(
size_t size,
char *tag,
char *routine_name,
char *cfile_name,
int line_number);
128 void *MEMRealloc(
void *p,
size_t size,
char *tag,
char *routine_name,
char *cfile_name,
int line_number);
129 char *MEMStrdup(
const char *
string,
char *tag,
char *routine_name,
char *cfile_name,
int line_number);
130 void MEMExit(
int status,
char *tag,
char *routine_name,
char *cfile_name,
int line_number);
136 #define memCalloc(NOBJ, SIZE, TAG) calloc(NOBJ, SIZE)
139 #define memFree(P, TAG) {free(P);P = NULL;}
141 #define memFree(P, TAG) free(P)
144 #define memMalloc(SIZE, TAG) malloc(SIZE)
145 #define memRealloc(P, SIZE, TAG) realloc(P, SIZE)
146 #define memStrdup(STRING, TAG) os_strdup(STRING)
147 #define memExit(STATUS, TAG) exit(STATUS)
151 #if MEMTRACK >= MEMTRACK_TRACE
154 #define memTrace(TAG) MEMTrace()
157 #define memTrace(MSG) MEMTrace(MSG, ROUTINE_NAME, __FILE__, __LINE__);
158 void MEMTrace(
char *msg,
char *routine_name,
char *cfile_name,
int line_number);
162 #define memTrace(MSG) ;
165 #if MEMTRACK == MEMTRACK_ULTRA
167 #define memStrcpy(S, CT, TAG) MEMStrcpy(S, CT, TAG, ROUTINE_NAME, __FILE__, __LINE__)
168 #define memStrncpy(S, CT, N, TAG) MEMStrncpy(S, CT, N, TAG, ROUTINE_NAME, __FILE__, __LINE__)
169 #define memStrcat(S, CT, TAG) MEMStrcat(S, CT, TAG, ROUTINE_NAME, __FILE__, __LINE__)
170 #define memStrncat(S, CT, N, TAG) MEMStrncat(S, CT, N, TAG, ROUTINE_NAME, __FILE__, __LINE__)
171 #define memStrcmp(CS, CT, TAG) MEMStrcmp(CS, CT, TAG, ROUTINE_NAME, __FILE__, __LINE__)
172 #define memStrncmp(CS, CT, N, TAG) MEMStrncmp(CS, CT, N, TAG, ROUTINE_NAME, __FILE__, __LINE__)
173 #define memStrchr(CS, C, TAG) MEMStrchr(CS, C, TAG, ROUTINE_NAME, __FILE__, __LINE__)
174 #define memStrrchr(CS, C, TAG) MEMStrrchr(CS, C, TAG, ROUTINE_NAME, __FILE__, __LINE__)
175 #define memStrstr(CS, CT, TAG) MEMStrstr(CS, CT, TAG, ROUTINE_NAME, __FILE__, __LINE__)
176 #define memMemcpy(S, CT, N, TAG) MEMMemcpy(S, CT, N, TAG, ROUTINE_NAME, __FILE__, __LINE__)
177 #define memMemmove(S, CT, N, TAG) MEMMemmove(S, CT, N, TAG, ROUTINE_NAME, __FILE__, __LINE__)
178 #define memMemset(DEST, C, COUNT, TAG) MEMMemset(DEST, C, COUNT, TAG, ROUTINE_NAME, __FILE__, __LINE__)
181 char *MEMStrcpy(
char *s,
const char *ct);
182 char *MEMStrncpy(
char *s,
const char *ct,
size_t n);
183 char *MEMStrcat(
char *s,
const char *ct);
184 char *MEMStrncat(
char *s,
const char *ct,
size_t n);
185 int MEMStrcmp(
const char *cs,
const char *ct);
186 int MEMStrncmp(
const char *cs,
const char *ct,
size_t n);
187 char *MEMStrchr(
const char *cs,
int c);
188 char *MEMStrrchr(
const char *cs,
int c);
189 char *MEMStrstr(
const char *cs,
const char *ct);
190 void *MEMMemset(
void *dest,
int c,
unsigned int count);
192 #if FF_CC == FF_CC_MSVC1 || FF_CC == FF_CC_MSVC4 || FF_CC == FF_CC_MACCW
194 void *MEMMemcpy(
void *s,
const void *ct,
size_t n);
195 void *MEMMemmove(
void *s,
const void *ct,
size_t n);
199 #if FF_CC == FF_CC_UNIX
201 char *MEMMemcpy(
char *s,
const char *ct,
size_t n);
202 char *MEMMemmove(
char *s,
const char *ct,
size_t n);
207 char *MEMStrcpy(
char *s,
const char *ct,
char *tag,
char *routine_name,
char *cfile_name,
int line_number);
208 char *MEMStrncpy(
char *s,
const char *ct,
size_t n,
char *tag,
char *routine_name,
char *cfile_name,
int line_number);
209 char *MEMStrcat(
char *s,
const char *ct,
char *tag,
char *routine_name,
char *cfile_name,
int line_number);
210 char *MEMStrncat(
char *s,
const char *ct,
size_t n,
char *tag,
char *routine_name,
char *cfile_name,
int line_number);
211 int MEMStrcmp(
const char *cs,
const char *ct,
char *tag,
char *routine_name,
char *cfile_name,
int line_number);
212 int MEMStrncmp(
const char *cs,
const char *ct,
size_t n,
char *tag,
char *routine_name,
char *cfile_name,
int line_number);
213 char *MEMStrchr(
const char *cs,
int c,
char *tag,
char *routine_name,
char *cfile_name,
int line_number);
214 char *MEMStrrchr(
const char *cs,
int c,
char *tag,
char *routine_name,
char *cfile_name,
int line_number);
215 char *MEMStrstr(
const char *cs,
const char *ct,
char *tag,
char *routine_name,
char *cfile_name,
int line_number);
216 void *MEMMemset(
void *dest,
int c,
unsigned int count,
char *tag,
char *routine_name,
char *cfile_name,
int line_number);
218 #if FF_CC == FF_CC_MSVC1 || FF_CC == FF_CC_MSVC4 || FF_CC == FF_CC_MACCW
220 void *MEMMemcpy(
void *s,
const void *ct,
size_t n,
char *tag,
char *routine_name,
char *cfile_name,
int line_number);
221 void *MEMMemmove(
void *s,
const void *ct,
size_t n,
char *tag,
char *routine_name,
char *cfile_name,
int line_number);
225 #if FF_CC == FF_CC_UNIX
227 char *MEMMemcpy(
char *s,
const char *ct,
size_t n,
char *tag,
char *routine_name,
char *cfile_name,
int line_number);
228 char *MEMMemmove(
char *s,
const char *ct,
size_t n,
char *tag,
char *routine_name,
char *cfile_name,
int line_number);
236 #define memStrcpy(S, CT, TAG) strcpy(S, CT)
237 #define memStrncpy(S, CT, N, TAG) strncpy(S, CT, N)
238 #define memStrcat(S, CT, TAG) strcat(S, CT)
239 #define memStrncat(S, CT, N, TAG) strncat(S, CT, N)
240 #define memStrcmp(CS, CT, TAG) strcmp(CS, CT)
241 #define memStrncmp(CS, CT, N, TAG) strncmp(CS, CT, N)
242 #define memStrchr(CS, C, TAG) strchr(CS, C)
243 #define memStrrchr(CS, C, TAG) strrchr(CS, C)
244 #define memStrstr(CS, CT, TAG) strstr(CS, CT)
245 #define memMemcpy(S, CT, N, TAG) memcpy(S, CT, N)
246 #define memMemmove(S, CT, N, TAG) memmove(S, CT, N)
247 #define memMemset(DEST,C,COUNT,TAG) memset(DEST,C,COUNT)
struct memtrack_entry_struct_t FF_MEM_ENTRY
struct memtrack_entry_struct_t * FF_MEM_ENTRY_PTR
struct memtrack_log FF_MEM_LOG
struct memtrack_entry_struct_t ** FF_MEM_ENTRY_HANDLE
struct memtrack_log * FF_MEM_LOG_PTR
struct memtrack_log ** FF_MEM_LOG_HANDLE