2015-08-26 15:18:01 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace memory_helper
|
|
|
|
{
|
|
|
|
/**
|
2016-06-27 16:34:08 +00:00
|
|
|
* Reserve `size` bytes of virtual memory and returns it.
|
2015-08-26 15:18:01 +00:00
|
|
|
* The memory should be commited before usage.
|
|
|
|
*/
|
2016-06-27 16:34:08 +00:00
|
|
|
void* reserve_memory(std::size_t size);
|
2015-08-26 15:18:01 +00:00
|
|
|
|
|
|
|
/**
|
2016-06-27 16:34:08 +00:00
|
|
|
* Commit `size` bytes of virtual memory starting at pointer.
|
2015-08-26 15:18:01 +00:00
|
|
|
* That is, bake reserved memory with physical memory.
|
|
|
|
* pointer should belong to a range of reserved memory.
|
|
|
|
*/
|
2016-06-27 16:34:08 +00:00
|
|
|
void commit_page_memory(void* pointer, std::size_t size);
|
2015-08-26 15:18:01 +00:00
|
|
|
|
|
|
|
/**
|
2016-06-27 16:34:08 +00:00
|
|
|
* Decommit all memory committed via commit_page_memory.
|
2015-08-26 15:18:01 +00:00
|
|
|
*/
|
2016-06-27 16:34:08 +00:00
|
|
|
void free_reserved_memory(void* pointer, std::size_t size);
|
|
|
|
}
|