source: golgotha/src/i4/memory/growheap.hh

Last change on this file 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.4 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
10/*
11   Grow heap will only grow, it never shrinks.
12   It should not be used for allocating large blocks.  And
13   the largest allocation request should be less than grow_increment.
14
15 */
16
17#ifndef __GROWHEAP_HPP_
18#define __GROWHEAP_HPP_
19
20#include "memory/malloc.hh"
21#include "isllist.hh"
22
23class i4_grow_heap_class
24{
25public:
26  class heap
27  {
28  public:
29    heap *next;
30    void *data;
31    heap(w32 size, char *name) { data=i4_malloc(size,name); name=0; }
32    ~heap() { i4_free(data); }
33  } ;
34
35  typedef i4_isl_list<heap>           heap_list;
36  typedef i4_isl_list<heap>::iterator heap_iter;
37
38  heap_list list;
39  w32 current_offset,increment,current_size;
40
41  i4_grow_heap_class(w32 initial_size, w32 grow_increment);
42  void *malloc(w32 size, char *description);           // description not used right now
43  ~i4_grow_heap_class() { list.destroy_all(); }
44  void clear();
45} ;
46
47
48#endif
Note: See TracBrowser for help on using the repository browser.