From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a02534.html | 444 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 444 insertions(+) create mode 100644 docs/doxygen/nel/a02534.html (limited to 'docs/doxygen/nel/a02534.html') diff --git a/docs/doxygen/nel/a02534.html b/docs/doxygen/nel/a02534.html new file mode 100644 index 00000000..15a5f97f --- /dev/null +++ b/docs/doxygen/nel/a02534.html @@ -0,0 +1,444 @@ + + +NeL: NLMISC::CFixedSizeAllocator::CChunk class Reference + + + +
+

NLMISC::CFixedSizeAllocator::CChunk Class Reference

+ + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

void add ()
 a chunk has been given back

 CChunk ()
uint getBlockSizeWithOverhead () const
CNodegetNode (uint index)
void grab ()
 a chunk has been taken

void init (CFixedSizeAllocator *fsa)
 ~CChunk ()

Data Fields

CFixedSizeAllocatorAllocator
uint8Mem
uint NumFreeObjs
+

Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + +
NLMISC::CFixedSizeAllocator::CChunk::CChunk  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 94 of file fixed_size_allocator.cpp. +

+References Allocator, and NumFreeObjs. +

+

00095 {
+00096         NumFreeObjs = 0;
+00097         Allocator = NULL;
+00098 }
+
+

+ + + + +
+ + + + + + + + + +
NLMISC::CFixedSizeAllocator::CChunk::~CChunk  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 101 of file fixed_size_allocator.cpp. +

+References NLMISC::CFixedSizeAllocator::_NumChunks, Allocator, getNode(), NLMISC::CFixedSizeAllocator::getNumBlockPerChunk(), nlassert, NumFreeObjs, uint, and NLMISC::CFixedSizeAllocator::CNode::unlink(). +

+

00102 {               
+00103         nlassert(Allocator);
+00104         for (uint k = 0; k < Allocator->getNumBlockPerChunk(); ++k)
+00105         {
+00106                 getNode(k).unlink();
+00107         }
+00108         nlassert(NumFreeObjs == 0);
+00109         nlassert(Allocator->_NumChunks > 0);
+00110         -- (Allocator->_NumChunks);
+00111         delete Mem;
+00112 }
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + +
void NLMISC::CFixedSizeAllocator::CChunk::add  )  [inline]
+
+ + + + + +
+   + + +

+a chunk has been given back +

+ +

+Definition at line 154 of file fixed_size_allocator.cpp. +

+References NLMISC::CFixedSizeAllocator::_NumChunks, Allocator, NLMISC::CFixedSizeAllocator::getNumBlockPerChunk(), nlassert, and NumFreeObjs. +

+Referenced by NLMISC::CFixedSizeAllocator::CNode::link(). +

+

00155 {
+00156         nlassert(Allocator);
+00157         // a node of this chunk has been given back
+00158         nlassert(NumFreeObjs < Allocator->getNumBlockPerChunk());
+00159         ++ NumFreeObjs;
+00160         if (NumFreeObjs == Allocator->getNumBlockPerChunk()) // all objects back ?
+00161         {               
+00162                 if (Allocator->_NumChunks > 1) // we want to have at least one chunk left
+00163                 {
+00164                         delete this; // kill that object
+00165                 }               
+00166         }
+00167 }
+
+

+ + + + +
+ + + + + + + + + +
uint NLMISC::CFixedSizeAllocator::CChunk::getBlockSizeWithOverhead  )  const
+
+ + + + + +
+   + + +

+ +

+Definition at line 88 of file fixed_size_allocator.cpp. +

+References Allocator, NLMISC::CFixedSizeAllocator::getNumBytesPerBlock(), and uint. +

+Referenced by getNode(), and init(). +

+

00089 {
+00090         return std::max(sizeof(CNode) - offsetof(CNode, Next), Allocator->getNumBytesPerBlock()) + offsetof(CNode, Next);       
+00091 }
+
+

+ + + + +
+ + + + + + + + + + +
CFixedSizeAllocator::CNode & NLMISC::CFixedSizeAllocator::CChunk::getNode uint  index  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 146 of file fixed_size_allocator.cpp. +

+References Allocator, getBlockSizeWithOverhead(), NLMISC::CFixedSizeAllocator::getNumBlockPerChunk(), index, nlassert, uint, and uint8. +

+Referenced by init(), and ~CChunk(). +

+

00147 {
+00148         nlassert(Allocator);
+00149         nlassert(index < Allocator->getNumBlockPerChunk());
+00150         return *(CNode *) ((uint8 *) Mem + index * getBlockSizeWithOverhead());
+00151 }
+
+

+ + + + +
+ + + + + + + + + +
void NLMISC::CFixedSizeAllocator::CChunk::grab  )  [inline]
+
+ + + + + +
+   + + +

+a chunk has been taken +

+ +

+Definition at line 170 of file fixed_size_allocator.cpp. +

+References nlassert, and NumFreeObjs. +

+Referenced by NLMISC::CFixedSizeAllocator::CNode::unlink(). +

+

00171 {
+00172         // a node of this chunk has been given back
+00173         nlassert(NumFreeObjs > 0);
+00174         -- NumFreeObjs;         
+00175 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLMISC::CFixedSizeAllocator::CChunk::init CFixedSizeAllocator alloc  ) 
+
+ + + + + +
+   + + +

+init all the element as a linked list +

+Definition at line 115 of file fixed_size_allocator.cpp. +

+References Allocator, NLMISC::CFixedSizeAllocator::CNode::Chunk, getBlockSizeWithOverhead(), getNode(), NLMISC::CFixedSizeAllocator::CNode::Next, nlassert, NumFreeObjs, NLMISC::CFixedSizeAllocator::CNode::Prev, uint, and uint8. +

+Referenced by NLMISC::CFixedSizeAllocator::alloc(). +

+

00116 {
+00117         nlassert(!Allocator);
+00118         nlassert(alloc);
+00119         Allocator = alloc;
+00120         //
+00121         Mem = new uint8[getBlockSizeWithOverhead() * alloc->getNumBlockPerChunk()];     
+00122         //
+00123         getNode(0).Chunk = this;
+00124         getNode(0).Next = &getNode(1);
+00125         getNode(0).Prev = &alloc->_FreeSpace;
+00126         //
+00127         NumFreeObjs = alloc->getNumBlockPerChunk();
+00129         for (uint k = 1; k < (NumFreeObjs - 1); ++k)
+00130         {
+00131                 getNode(k).Chunk = this;
+00132                 getNode(k).Next = &getNode(k + 1);
+00133                 getNode(k).Prev = &getNode(k - 1).Next;
+00134         }
+00135         
+00136         getNode(NumFreeObjs - 1).Chunk = this;
+00137         getNode(NumFreeObjs - 1).Next  = alloc->_FreeSpace;
+00138         getNode(NumFreeObjs - 1).Prev = &(getNode(NumFreeObjs - 2).Next);
+00139         
+00140         if (alloc->_FreeSpace) { alloc->_FreeSpace->Prev = &getNode(NumFreeObjs - 1).Next; }
+00141         alloc->_FreeSpace = &getNode(0);
+00142         ++(alloc->_NumChunks);
+00143 }
+
+


Field Documentation

+

+ + + + +
+ + +
CFixedSizeAllocator* NLMISC::CFixedSizeAllocator::CChunk::Allocator +
+
+ + + + + +
+   + + +

+ +

+Definition at line 86 of file fixed_size_allocator.h. +

+Referenced by add(), CChunk(), NLMISC::CFixedSizeAllocator::free(), getBlockSizeWithOverhead(), getNode(), init(), NLMISC::CFixedSizeAllocator::CNode::link(), and ~CChunk().

+

+ + + + +
+ + +
uint8* NLMISC::CFixedSizeAllocator::CChunk::Mem +
+
+ + + + + +
+   + + +

+ +

+Definition at line 87 of file fixed_size_allocator.h.

+

+ + + + +
+ + +
uint NLMISC::CFixedSizeAllocator::CChunk::NumFreeObjs +
+
+ + + + + +
+   + + +

+ +

+Definition at line 85 of file fixed_size_allocator.h. +

+Referenced by add(), CChunk(), grab(), init(), NLMISC::CFixedSizeAllocator::CNode::unlink(), and ~CChunk().

+


The documentation for this class was generated from the following files: +
Generated on Tue Mar 16 13:13:23 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1