#include <MemoryPool.h>
Inheritance diagram for OpenDDS::DCPS::FreeHeader:
Public Member Functions | |
void | init_free_block (unsigned int pool_size) |
void | set_free () |
FreeHeader * | smaller_free (unsigned char *pool_base) const |
FreeHeader * | larger_free (unsigned char *pool_base) const |
void | set_smaller_free (FreeHeader *next, unsigned char *pool_base) |
void | set_larger_free (FreeHeader *prev, unsigned char *pool_base) |
Private Attributes | |
size_t | offset_smaller_free_ |
Offset to smaller free block in size order. | |
size_t | offset_larger_free_ |
Offset to larger free block in size order. |
Definition at line 64 of file MemoryPool.h.
void OpenDDS::DCPS::FreeHeader::init_free_block | ( | unsigned int | pool_size | ) |
Initialize the first AllocHeader with its size
Definition at line 88 of file MemoryPool.cpp.
References OpenDDS::DCPS::AllocHeader::alloc_size_, OpenDDS::DCPS::AllocHeader::prev_size_, and set_free().
Referenced by OpenDDS::DCPS::MemoryPool::MemoryPool().
00089 { 00090 alloc_size_ = static_cast<int>(pool_size - sizeof(AllocHeader)); 00091 prev_size_ = 0; 00092 set_free(); 00093 }
FreeHeader * OpenDDS::DCPS::FreeHeader::larger_free | ( | unsigned char * | pool_base | ) | const |
Get next equal or larger free block in size order
Definition at line 116 of file MemoryPool.cpp.
References offset_larger_free_.
Referenced by OpenDDS::DCPS::MemoryPool::remove_free_alloc().
00117 { 00118 FreeHeader* result = NULL; 00119 if (offset_larger_free_ != std::numeric_limits<size_t>::max()) { 00120 result = reinterpret_cast<FreeHeader*>(pool_base + offset_larger_free_); 00121 } 00122 return result; 00123 }
void OpenDDS::DCPS::FreeHeader::set_free | ( | ) |
Mark as free
Definition at line 96 of file MemoryPool.cpp.
References OpenDDS::DCPS::AllocHeader::alloc_size_, OpenDDS::DCPS::AllocHeader::is_free(), set_larger_free(), and set_smaller_free().
Referenced by init_free_block().
00097 { 00098 // If this is newly freed 00099 if (!is_free()) { 00100 alloc_size_ *= -1; 00101 set_smaller_free(NULL, NULL); 00102 set_larger_free(NULL, NULL); 00103 } 00104 }
void OpenDDS::DCPS::FreeHeader::set_larger_free | ( | FreeHeader * | prev, | |
unsigned char * | pool_base | |||
) |
Set the next equal or larger free block in size order
Definition at line 136 of file MemoryPool.cpp.
References offset_larger_free_.
Referenced by OpenDDS::DCPS::MemoryPool::insert_free_alloc(), OpenDDS::DCPS::MemoryPool::remove_free_alloc(), and set_free().
00137 { 00138 if (prev) { 00139 offset_larger_free_ = reinterpret_cast<unsigned char*>(prev) - pool_base; 00140 } else { 00141 offset_larger_free_ = std::numeric_limits<size_t>::max(); 00142 } 00143 }
void OpenDDS::DCPS::FreeHeader::set_smaller_free | ( | FreeHeader * | next, | |
unsigned char * | pool_base | |||
) |
Set the next equal or smaller free block in size order
Definition at line 126 of file MemoryPool.cpp.
References offset_smaller_free_.
Referenced by OpenDDS::DCPS::MemoryPool::insert_free_alloc(), OpenDDS::DCPS::MemoryPool::remove_free_alloc(), and set_free().
00127 { 00128 if (next) { 00129 offset_smaller_free_ = reinterpret_cast<unsigned char*>(next) - pool_base; 00130 } else { 00131 offset_smaller_free_ = std::numeric_limits<size_t>::max(); 00132 } 00133 }
FreeHeader * OpenDDS::DCPS::FreeHeader::smaller_free | ( | unsigned char * | pool_base | ) | const |
Get next equal or smaller free block in size order
Definition at line 106 of file MemoryPool.cpp.
References offset_smaller_free_.
Referenced by OpenDDS::DCPS::FreeIndex::find(), OpenDDS::DCPS::MemoryPool::insert_free_alloc(), and OpenDDS::DCPS::MemoryPool::remove_free_alloc().
00107 { 00108 FreeHeader* result = NULL; 00109 if (offset_smaller_free_ != std::numeric_limits<size_t>::max()) { 00110 result = reinterpret_cast<FreeHeader*>(pool_base + offset_smaller_free_); 00111 } 00112 return result; 00113 }
size_t OpenDDS::DCPS::FreeHeader::offset_larger_free_ [private] |
Offset to larger free block in size order.
Definition at line 84 of file MemoryPool.h.
Referenced by larger_free(), and set_larger_free().
size_t OpenDDS::DCPS::FreeHeader::offset_smaller_free_ [private] |
Offset to smaller free block in size order.
Definition at line 83 of file MemoryPool.h.
Referenced by set_smaller_free(), and smaller_free().