source: golgotha/src/i4/memory/malloc.hh @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 12 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 1.8 KB
Line 
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
20void *i4_malloc(w32 size, char *file, int line);
21void *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>
29extern 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
41void i4_set_max_memory_used(int bytes);
42void i4_set_min_memory_required(int bytes);
43
44void i4_free(void *ptr);
45
46void i4_mem_report(char *filename);
47long i4_allocated();
48long i4_available();
49long i4_largest_free_block();
50
51// for debugging purposes only...
52int valid_ptr(void *ptr);        // returns 1 if is an address returned by i4_malloc
53int valid_memory(void *ptr);     // returns 1 if address is in memory space managed by i4
54
55#endif
Note: See TracBrowser for help on using the repository browser.