OpenDDS::DCPS::FreeHeader Class Reference

#include <MemoryPool.h>

Inheritance diagram for OpenDDS::DCPS::FreeHeader:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::FreeHeader:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void init_free_block (unsigned int pool_size)
void set_free ()
FreeHeadersmaller_free (unsigned char *pool_base) const
FreeHeaderlarger_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.

Detailed Description

Header of free allocations - found at beginning of allocation inside pool. This forces a minimum allocation size, so that, when freed, header can be cast to this type.

Definition at line 66 of file MemoryPool.h.


Member Function Documentation

void OpenDDS::DCPS::FreeHeader::init_free_block ( unsigned int  pool_size  ) 

Initialize the first AllocHeader with its size

Definition at line 90 of file MemoryPool.cpp.

References OpenDDS::DCPS::AllocHeader::alloc_size_, OpenDDS::DCPS::AllocHeader::prev_size_, and set_free().

Referenced by OpenDDS::DCPS::MemoryPool::MemoryPool().

00091 {
00092   alloc_size_ = static_cast<int>(pool_size - sizeof(AllocHeader));
00093   prev_size_ = 0;
00094   set_free();
00095 }

Here is the call graph for this function:

Here is the caller graph for this function:

FreeHeader * OpenDDS::DCPS::FreeHeader::larger_free ( unsigned char *  pool_base  )  const

Get next equal or larger free block in size order

Definition at line 118 of file MemoryPool.cpp.

References offset_larger_free_.

Referenced by OpenDDS::DCPS::MemoryPool::remove_free_alloc().

00119 {
00120   FreeHeader* result = NULL;
00121   if (offset_larger_free_ != std::numeric_limits<size_t>::max()) {
00122     result = reinterpret_cast<FreeHeader*>(pool_base + offset_larger_free_);
00123   }
00124   return result;
00125 }

Here is the caller graph for this function:

void OpenDDS::DCPS::FreeHeader::set_free (  ) 

Mark as free

Definition at line 98 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(), and OpenDDS::DCPS::MemoryPool::pool_free().

00099 {
00100   // If this is newly freed
00101   if (!is_free()) {
00102     alloc_size_ *= -1;
00103     set_smaller_free(NULL, NULL);
00104     set_larger_free(NULL, NULL);
00105   }
00106 }

Here is the call graph for this function:

Here is the caller graph for this function:

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 138 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().

00139 {
00140   if (prev) {
00141     offset_larger_free_ = reinterpret_cast<unsigned char*>(prev) - pool_base;
00142   } else {
00143     offset_larger_free_ = std::numeric_limits<size_t>::max();
00144   }
00145 }

Here is the caller graph for this function:

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 128 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().

00129 {
00130   if (next) {
00131     offset_smaller_free_ = reinterpret_cast<unsigned char*>(next) - pool_base;
00132   } else {
00133     offset_smaller_free_ = std::numeric_limits<size_t>::max();
00134   }
00135 }

Here is the caller graph for this function:

FreeHeader * OpenDDS::DCPS::FreeHeader::smaller_free ( unsigned char *  pool_base  )  const

Get next equal or smaller free block in size order

Definition at line 108 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().

00109 {
00110   FreeHeader* result = NULL;
00111   if (offset_smaller_free_ != std::numeric_limits<size_t>::max()) {
00112     result = reinterpret_cast<FreeHeader*>(pool_base + offset_smaller_free_);
00113   }
00114   return result;
00115 }

Here is the caller graph for this function:


Member Data Documentation

Offset to larger free block in size order.

Definition at line 86 of file MemoryPool.h.

Referenced by larger_free(), and set_larger_free().

Offset to smaller free block in size order.

Definition at line 85 of file MemoryPool.h.

Referenced by set_smaller_free(), and smaller_free().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1