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

Last change on this file since 80 was 80, checked in by Sam Hocevar, 11 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.9 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 BMANAGE_HH__
10#define BMANAGE_HH__
11
12#include "arch.hh"
13#include "memory/malloc.hh"
14class i4_file_class;  // file/file.hh
15
16struct memory_node
17{
18  sw32 size;
19#ifdef i4_MEM_CHECK
20  char *name;                     // name is allocated on regular heap
21#endif                            // because it is used for debugging purposes
22                                  // and will probably be run on my linux box with VMM
23  memory_node *next;
24};
25
26
27struct small_block
28
29  sw32 size;                     // size of blocks...
30  w32 alloc_list;               // bit field saying weither each block is allocated or not.
31  small_block *next;                      // next small block of same size
32#ifdef i4_MEM_CHECK
33  char *name[32];
34#endif
35} ;
36
37// above 128 bytes is considered to be a big block and no hashing is done
38#define JM_SMALL_SIZE 128     
39
40class i4_block_manager_class
41{
42  public :
43
44  sw32 block_size;                             // size of this memory_block
45  small_block *sblocks[JM_SMALL_SIZE];
46  void *addr;
47
48  memory_node *sfirst,*slast;
49
50
51  void init(void *block, long Block_size);
52  void *alloc(long size, char *name);
53  void free(void *ptr);
54
55  long largest_free_block();
56  long available();
57  long allocated();
58  long pointer_size(void *ptr);
59  void report(i4_file_class *fp);
60  void inspect();
61
62  int valid_ptr(void *ptr);     // only called from within debugger
63};
64
65#endif
Note: See TracBrowser for help on using the repository browser.