MCPcopy Create free account
hub / github.com/csyonghe/Spire / Init

Method Init

Source/CoreLib/MemoryPool.cpp:12–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10 Init(pBuffer, pLog2BlockSize, numBlocks);
11 }
12 void MemoryPool::Init(unsigned char * pBuffer, int pLog2BlockSize, int numBlocks)
13 {
14 assert(pLog2BlockSize >= 1 && pLog2BlockSize <= 30);
15 assert(numBlocks >= 4);
16 buffer = pBuffer;
17 blockSize = 1 << pLog2BlockSize;
18 log2BlockSize = pLog2BlockSize;
19 numLevels = Math::Log2Floor(numBlocks);
20 freeList[0] = (FreeListNode*)buffer;
21 freeList[0]->NextPtr = nullptr;
22 freeList[0]->PrevPtr = nullptr;
23 used.SetMax(1 << (numLevels));
24 for (int i = 1; i < MaxLevels; i++)
25 {
26 freeList[i] = nullptr;
27 }
28 }
29 int MemoryPool::AllocBlock(int level)
30 {
31 if (level < 0)

Callers

nothing calls this directly

Calls 1

SetMaxMethod · 0.80

Tested by

no test coverage detected