cgma
|
00001 //- Class: MemoryBlock 00002 //- Owner: Jim Hipp 00003 //- Description: MemoryBlock provides stack storage for block or "Chunk" 00004 //- memory allocated with overloaded 'new' operators in classes 00005 //- utilizing a MemoryManager object. 00006 //- Checked By: 00007 //- Version: 00008 00009 #ifndef MEMORY_BLOCK_HPP 00010 #define MEMORY_BLOCK_HPP 00011 00012 #include <cstdlib> 00013 #include "CGMUtilConfigure.h" 00014 00015 class CUBIT_UTIL_EXPORT MemoryBlock 00016 { 00017 private: 00018 00019 char* block; 00020 int size; 00021 MemoryBlock* next; 00022 //- block is the pointer to the beginning of the memory block of objects 00023 //- of type char, size is the size of the memory block, and next is a 00024 //- pointer to the next MemoryBlock object. 00025 00026 public: 00027 00028 MemoryBlock (MemoryBlock* Head, char* Block, int Size) 00029 : block(Block), size(Size), next(Head) {} 00030 //- Constructor: performs initialization assignment 00031 00032 ~MemoryBlock(); 00033 //- Destructor: performs recursive delete of MemoryBlock stack 00034 00035 int get_memory_allocation(); 00036 //- returns total amount of allocated memory (bytes) 00037 00038 MemoryBlock* next_block() const; 00039 void next_block(MemoryBlock* next_block); 00040 //- retreive / set next pointer 00041 00042 int block_size() const; 00043 //- get block_size 00044 00045 char* get_block() const; 00046 //- get block 00047 }; 00048 00049 inline MemoryBlock* MemoryBlock::next_block() const 00050 { 00051 return next; 00052 } 00053 00054 inline void MemoryBlock::next_block(MemoryBlock* nxt_blck) 00055 { 00056 next = nxt_blck; 00057 } 00058 00059 inline int MemoryBlock::block_size() const 00060 { 00061 return size; 00062 } 00063 00064 inline char* MemoryBlock::get_block() const 00065 { 00066 return block; 00067 } 00068 00069 #endif // MEMORY_BLOCK_HPP 00070