utils::memory update

This commit is contained in:
Nekotekina 2017-03-19 15:50:56 +03:00
parent c2cd0c994f
commit c7a9a8e8f1
2 changed files with 55 additions and 46 deletions

View file

@ -2,24 +2,6 @@
namespace utils
{
/**
* Reserve `size` bytes of virtual memory and returns it.
* The memory should be commited before usage.
*/
void* memory_reserve(std::size_t size);
/**
* Commit `size` bytes of virtual memory starting at pointer.
* That is, bake reserved memory with physical memory.
* pointer should belong to a range of reserved memory.
*/
void memory_commit(void* pointer, std::size_t size);
/**
* Decommit all memory committed via commit_page_memory.
*/
void memory_decommit(void* pointer, std::size_t size);
// Memory protection type
enum class protection
{
@ -30,5 +12,24 @@ namespace utils
rx, // Read + execute
};
/**
* Reserve `size` bytes of virtual memory and returns it.
* The memory should be commited before usage.
*/
void* memory_reserve(std::size_t size, void* use_addr = nullptr);
/**
* Commit `size` bytes of virtual memory starting at pointer.
* That is, bake reserved memory with physical memory.
* pointer should belong to a range of reserved memory.
*/
void memory_commit(void* pointer, std::size_t size, protection prot = protection::rw);
/**
* Decommit all memory committed via commit_page_memory.
*/
void memory_decommit(void* pointer, std::size_t size);
// Set memory protection
void memory_protect(void* pointer, std::size_t size, protection prot);
}