| 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 | { |
no test coverage detected