Eneboo - Documentación para desarrolladores
|
00001 #ifndef _KINGSMODHEAP_H_ 00002 #define _KINGSMODHEAP_H_ 00003 00004 #include "segheap.h" 00005 00006 /* KingsMod (segregated fits) allocator */ 00007 00008 namespace KingsMod { 00009 00010 inline size_t class2Size (int i); 00011 00012 inline int pow2Class (size_t sz) { 00013 static size_t sizeTable[] = {8UL, 16UL, 24UL, 32UL, 40UL, 48UL, 56UL, 72UL, 80UL, 96UL, 120UL, 144UL, 168UL, 200UL, 240UL, 288UL, 344UL, 416UL, 496UL, 592UL, 712UL, 856UL, 1024UL, 1232UL, 1472UL, 1768UL, 2120UL, 2544UL, 3048UL, 3664UL}; 00014 int c = 0; 00015 while (c < 30 && sz < sizeTable[c]) { 00016 c++; 00017 } 00018 return c; 00019 } 00020 00021 inline size_t class2Size (int i) { 00022 assert (i >= 0); 00023 assert (i < 30); 00024 static size_t sizeTable[] = {8UL, 16UL, 24UL, 32UL, 40UL, 48UL, 56UL, 72UL, 80UL, 96UL, 120UL, 144UL, 168UL, 200UL, 240UL, 288UL, 344UL, 416UL, 496UL, 592UL, 712UL, 856UL, 1024UL, 1232UL, 1472UL, 1768UL, 2120UL, 2544UL, 3048UL, 3664UL}; 00025 return sizeTable[i]; 00026 } 00027 00028 }; 00029 00030 00031 template <class PerClassHeap> 00032 class KingsModHeap : public SegHeap<29, KingsMod::pow2Class, KingsMod::class2Size, PerClassHeap, PerClassHeap> {}; 00033 00034 #endif