MCPcopy Create free account
hub / github.com/defold/defold / Alloc

Function Alloc

engine/dlib/src/dlib/poolallocator.cpp:65–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63 }
64
65 void* Alloc(HPool pool, uint32_t size)
66 {
67 assert(size <= pool->m_PageSize);
68
69 Page* p = pool->m_CurrentPage;
70 uint32_t left = pool->m_PageSize - p->m_Current;
71 if (left < size)
72 {
73 char* page_buffer = new char[sizeof(Page) + pool->m_PageSize];
74 Page* new_page = new (page_buffer) Page;
75 new_page->m_Next = p;
76 pool->m_CurrentPage = new_page;
77 p = new_page;
78 }
79
80 void* ret = (void*) &p->m_Buffer[p->m_Current];
81 p->m_Current += size;
82 return ret;
83 }
84
85 char* Duplicate(HPool pool, const char* string)
86 {

Callers 2

DuplicateFunction · 0.70
TESTFunction · 0.50

Calls 1

assertFunction · 0.50

Tested by 1

TESTFunction · 0.40