#include <string.h>#include "Error.hpp"Go to the source code of this file.
Defines | |
| #define | BLOCKSIZE_NUM 4 | 
| #define | LARGEBLOCK_SIZE 65536 | 
| #define | MEDIUMBLOCK_SIZE 8192 | 
| #define | SMALLBLOCK_SIZE 1024 | 
| #define | TINYBLOCK_SIZE 256 | 
Functions | |
| char * | AllocateBlockRecurs (unsigned char blocksizeidx) | 
| char * | AllocateBlock (unsigned char blocksizeidx) | 
| void | FreeBlock (char *ptr, unsigned char blocksizeidx) | 
| unsigned long | GetBlockSize (unsigned char blocksizeidx) | 
Variables | |
| unsigned long | blocksizes [] | 
| char * | freeblocklists [] | 
| unsigned long | allocatedmemory | 
      
  | 
  
| 
 
 Definition at line 37 of file MemMan.hpp.  | 
  
      
  | 
  
| 
 
 Definition at line 39 of file MemMan.hpp.  | 
  
      
  | 
  
| 
 
 Definition at line 40 of file MemMan.hpp.  | 
  
      
  | 
  
| 
 
 Definition at line 41 of file MemMan.hpp.  | 
  
      
  | 
  
| 
 
 Definition at line 42 of file MemMan.hpp.  | 
  
      
  | 
  
| 
 
 Definition at line 63 of file MemMan.hpp. 00066 {
00067    allocatedmemory+=blocksizes[blocksizeidx];
00068    return AllocateBlockRecurs(blocksizeidx);
00069 }
 | 
  
      
  | 
  
| 
 
 Definition at line 51 of file MemMan.cpp. 00055 {
00056    char *ptr;
00057 
00058    // Do we have any free block?
00059    if(freeblocklists[blocksizeidx]!=NULL)
00060    {
00061       ptr=freeblocklists[blocksizeidx];
00062       freeblocklists[blocksizeidx]=*(char **)freeblocklists[blocksizeidx];
00063       return ptr;
00064    }
00065    else
00066    {
00067       if(blocksizeidx==BLOCKSIZE_NUM-1)
00068          // Is this the largest possible block size??
00069          // We must allocate new space!
00070       {
00071          ptr=(char *)malloc(blocksizes[blocksizeidx]);
00072          if(ptr==NULL)
00073             ExitNoMem();
00074 
00075          return ptr;
00076       }
00077       else  // If we haven't reached the largest possible block size,
00078             // We allocate a block of the next larger block size
00079             // and use it as a container for our blocks
00080       {
00081          ptr=AllocateBlockRecurs(blocksizeidx+1);
00082 
00083          // We add the new blocks to the free list
00084          char  *ptr1=ptr+blocksizes[blocksizeidx],
00085                *endptr=ptr+blocksizes[blocksizeidx+1];
00086 
00087          do
00088          {
00089             *(char **)ptr1=freeblocklists[blocksizeidx];
00090             freeblocklists[blocksizeidx]=ptr1;
00091 
00092             ptr1+=blocksizes[blocksizeidx];
00093          }
00094          while(ptr1<endptr);
00095 
00096          return ptr;
00097       }
00098    }
00099 }
 | 
  
      
  | 
  ||||||||||||
| 
 
 Definition at line 71 of file MemMan.hpp.  | 
  
      
  | 
  
| 
 
 Definition at line 84 of file MemMan.hpp. 00086 {
00087    return blocksizes[blocksizeidx];
00088 }
 | 
  
      
  | 
  
| 
 
 Definition at line 56 of file MemMan.hpp.  | 
  
      
  | 
  
| 
 
 Definition at line 44 of file MemMan.hpp.  | 
  
      
  | 
  
| 
 
 Definition at line 47 of file MemMan.hpp.  | 
  
1.2.11.1 written by Dimitri van Heesch,
 © 1997-2001