Eneboo - Documentación para desarrolladores
|
00001 // -*- C++ -*- 00002 00003 #ifndef _LAZYHEAP_H_ 00004 #define _LAZYHEAP_H_ 00005 00006 template <class SuperHeap> 00007 class LazyHeap { 00008 public: 00009 00010 LazyHeap (void) 00011 : initialized (0) 00012 {} 00013 00014 ~LazyHeap (void) { 00015 if (initialized) { 00016 delete lazyheap; 00017 } 00018 } 00019 00020 inline void * malloc (size_t sz) { 00021 return getHeap()->malloc (sz); 00022 } 00023 inline void free (void * ptr) { 00024 getHeap()->free (ptr); 00025 } 00026 inline void clear (void) { 00027 if (initialized) { 00028 getHeap()->clear(); 00029 } 00030 } 00031 00032 private: 00033 00034 SuperHeap * getHeap (void) { 00035 if (!initialized) { 00036 lazyheap = new SuperHeap; 00037 initialized = 1; 00038 } 00039 return lazyheap; 00040 } 00041 00042 bool initialized; 00043 SuperHeap * lazyheap; 00044 }; 00045 00046 00047 #endif