#include #include #include #include #include #if defined(_WIN32) #include namespace BGTU::ComputerGraphicsLabWork::Utilities { DefaultVoxelDrawerCache::ZElementAllocationBuffer::Page *DefaultVoxelDrawerCache::ZElementAllocationBuffer::_native_extend() { SYSTEM_INFO si; GetSystemInfo(&si); std::size_t size = max(si.dwPageSize, si.dwAllocationGranularity); void *raw = VirtualAlloc(nullptr, max(si.dwPageSize, si.dwAllocationGranularity), MEM_COMMIT, PAGE_READWRITE); if (raw == nullptr) throw std::bad_alloc{}; this->last_allocated_page->next = new(raw)Page(nullptr, Page::calc_capacity(size)); return this->last_allocated_page = this->last_allocated_page->next; } void DefaultVoxelDrawerCache::ZElementAllocationBuffer::_native_free_page(DefaultVoxelDrawerCache::ZElementAllocationBuffer::Page *p) { VirtualFree(p, 0, MEM_DECOMMIT | MEM_RELEASE); } } #else # error "" #endif