| 66 | static Result GetSocketNoLock(dmhash_t name_hash, HSocket* out_socket); |
| 67 | |
| 68 | static void AllocateNewPage(MemoryAllocator* allocator) |
| 69 | { |
| 70 | if (allocator->m_CurrentPage) |
| 71 | { |
| 72 | // Link current page to full pages |
| 73 | allocator->m_CurrentPage->m_NextPage = allocator->m_FullPages; |
| 74 | allocator->m_FullPages = allocator->m_CurrentPage; |
| 75 | } |
| 76 | |
| 77 | MemoryPage* new_page = 0; |
| 78 | |
| 79 | if (allocator->m_FreePages) |
| 80 | { |
| 81 | // Free page to use |
| 82 | new_page = allocator->m_FreePages; |
| 83 | allocator->m_FreePages = new_page->m_NextPage; |
| 84 | } |
| 85 | else |
| 86 | { |
| 87 | // Allocate new page |
| 88 | new_page = new MemoryPage; |
| 89 | } |
| 90 | |
| 91 | new_page->m_Current = 0; |
| 92 | new_page->m_NextPage = 0; |
| 93 | |
| 94 | allocator->m_CurrentPage = new_page; |
| 95 | } |
| 96 | |
| 97 | static void* AllocateMessage(MemoryAllocator* allocator, uint32_t size) |
| 98 | { |