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

Function AllocateMessage

engine/dlib/src/dlib/message.cpp:97–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95 }
96
97 static void* AllocateMessage(MemoryAllocator* allocator, uint32_t size)
98 {
99 // At least ALIGNMENT bytes alignment of size in order to ensure that the next allocation is aligned
100 size += DM_MESSAGE_ALIGNMENT-1;
101 size &= ~(DM_MESSAGE_ALIGNMENT-1);
102 assert(size <= DM_MESSAGE_PAGE_SIZE);
103
104 if (allocator->m_CurrentPage == 0 || (DM_MESSAGE_PAGE_SIZE-allocator->m_CurrentPage->m_Current) < size)
105 {
106 // No current page or allocation didn't fit.
107 AllocateNewPage(allocator);
108 }
109
110 MemoryPage* page = allocator->m_CurrentPage;
111 void* ret = (void*) ((uintptr_t) &page->m_Memory[0] + page->m_Current);
112 page->m_Current += size;
113 return ret;
114 }
115
116 struct MessageSocket
117 {

Callers 1

PostFunction · 0.85

Calls 2

AllocateNewPageFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected