Eneboo - Documentación para desarrolladores
|
00001 #ifndef _CHECKHEAP_H_ 00002 #define _CHECKHEAP_H_ 00003 00004 00005 template <class SuperHeap> 00006 class CheckHeap : public SuperHeap { 00007 private: 00008 enum { RECEIVED_A_NULL_OBJECT_FROM_MALLOC = 0 }; 00009 enum { RECEIVED_AN_UNALIGNED_OBJECT_FROM_MALLOC = 0 }; 00010 public: 00011 inline void * malloc (size_t sz) { 00012 void * addr = SuperHeap::malloc (sz); 00013 if (addr == NULL) { 00014 assert (RECEIVED_A_NULL_OBJECT_FROM_MALLOC); 00015 printf ("RECEIVED_A_NULL_OBJECT_FROM_MALLOC\n"); 00016 abort(); 00017 } 00018 if ((unsigned long) addr % sizeof(double) != 0) { 00019 assert (RECEIVED_AN_UNALIGNED_OBJECT_FROM_MALLOC); 00020 printf ("RECEIVED_AN_UNALIGNED_OBJECT_FROM_MALLOC\n"); 00021 abort(); 00022 } 00023 return addr; 00024 } 00025 }; 00026 00027 00028 00029 #endif