Main Page   Class Hierarchy   Compound List   File List   Compound Members  

free_store.h

00001 #ifndef CMA_FREE_STORE_DEFINED
00002 #define CMA_FREE_STORE_DEFINED
00003 
00004 #include <stdlib.h>
00005 
00006 namespace CMa
00007 {
00008 
00020         template<class Word, class Int, class Heap> class FreeStore
00021         {
00022         protected:
00023                 Heap& heap;
00024 
00025         public:
00026 
00027                 FreeStore(Heap& heap) : heap(heap)
00028                 {}
00029 
00030                 
00031                 
00032                 /* Interfaces used by the templates */
00033 
00039                 void init()
00040                 {
00041                         // Nothing for now
00042                 }
00043 
00051                 void verifyHalt() throw (Error)
00052                 {
00053                         // Nothing for now
00054                 }
00055 
00056                 void deInit()
00057                 {
00058                         // Nothing for now
00059                 }
00060 
00070                 inline Word malloc(Int size)
00071                 {
00072                         assert(size > (Int)0);
00073 
00074                         Int newNP = heap.getNP() - size;
00075                         if (!heap.verifyNP(newNP)) return (Word)0;
00076             else
00077             {
00078                 heap.setNP(newNP);
00079                 return (Word)newNP;
00080             }
00081                         
00082                 }
00083 
00091                 inline void free(Int addr) throw (Error)
00092                 {
00093                         // Nothing for now
00094                 }
00095         };
00096 }
00097 
00098 #endif
00099 

Generated on Tue Oct 12 03:30:44 1999 by doxygen1.2.18