1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #ifndef __I4_MALLOC_HPP_ |
---|
10 | #define __I4_MALLOC_HPP_ |
---|
11 | |
---|
12 | #include "arch.hh" |
---|
13 | |
---|
14 | #if 0 //( __linux && DEBUG ) |
---|
15 | #define i4_NEW_CHECK 1 |
---|
16 | #define i4_MEM_CHECK 1 |
---|
17 | #endif |
---|
18 | |
---|
19 | |
---|
20 | void *i4_malloc(w32 size, char *file, int line); |
---|
21 | void *i4_realloc(void *old_memory, w32 new_size, char *file, int line); |
---|
22 | |
---|
23 | // if new checking, all news are logged by file and line number |
---|
24 | // these logs can be obtained by calling i4_mem_report |
---|
25 | // this is avaiable only under gcc |
---|
26 | |
---|
27 | #ifdef i4_NEW_CHECK |
---|
28 | #include <stdlib.h> |
---|
29 | extern void *operator new( size_t size, char *file, w32 line); |
---|
30 | //extern void *operator new [](size_t size, char *file, w32 line); |
---|
31 | #define new new(__FILE__,__LINE__) |
---|
32 | |
---|
33 | #define i4_malloc(size, reason) i4_malloc(size, __FILE__, __LINE__) |
---|
34 | #define i4_realloc(old, new_size, reason) i4_realloc(old, new_size, __FILE__, __LINE__); |
---|
35 | #else |
---|
36 | #define i4_malloc(size, reason) i4_malloc(size, 0, 0) |
---|
37 | #define i4_realloc(old, new_size, reason) i4_realloc(old, new_size, 0,0) |
---|
38 | |
---|
39 | #endif |
---|
40 | |
---|
41 | void i4_set_max_memory_used(int bytes); |
---|
42 | void i4_set_min_memory_required(int bytes); |
---|
43 | |
---|
44 | void i4_free(void *ptr); |
---|
45 | |
---|
46 | void i4_mem_report(char *filename); |
---|
47 | long i4_allocated(); |
---|
48 | long i4_available(); |
---|
49 | long i4_largest_free_block(); |
---|
50 | |
---|
51 | // for debugging purposes only... |
---|
52 | int valid_ptr(void *ptr); // returns 1 if is an address returned by i4_malloc |
---|
53 | int valid_memory(void *ptr); // returns 1 if address is in memory space managed by i4 |
---|
54 | |
---|
55 | #endif |
---|