|
cbase 1.50.0
C/C++ Static Template
|
Direct wrappers over VirtualAlloc/mmap for page-level memory control. More...
Functions | |
| usize | mem_os_page_size (void) |
| Retrieves the operating system's virtual memory page size. | |
| void * | mem_os_reserve (usize size) |
| Reserves a contiguous block of virtual address space. | |
| b32 | mem_os_commit (void *ptr, usize size) |
| Commits physical RAM to a previously reserved virtual address block. | |
| void | mem_os_decommit (void *ptr, usize size) |
| Decommits physical RAM, returning it to the OS. | |
| void | mem_os_release (void *ptr, usize size) |
| Releases a reserved virtual address block entirely back to the OS. | |
Direct wrappers over VirtualAlloc/mmap for page-level memory control.
Commits physical RAM to a previously reserved virtual address block.
The committed memory is zero-initialized by the OS on first access. Commit size is rounded up to the OS page size internally.
Example:
| ptr | Pointer within a previously reserved block. |
| size | The amount of physical memory to commit. |
| void mem_os_decommit | ( | void * | ptr, |
| usize | size ) |
Decommits physical RAM, returning it to the OS.
The virtual address range remains reserved and can be committed again later without calling mem_os_reserve(). Any access to decommitted memory before recommitting is undefined behavior (access violation / segfault).
Example:
| ptr | Pointer to the start of the committed range. |
| size | The amount of memory to decommit. |
Definition at line 39 of file mem_os.c.

| usize mem_os_page_size | ( | void | ) |
Retrieves the operating system's virtual memory page size.
Example:
| void mem_os_release | ( | void * | ptr, |
| usize | size ) |
Releases a reserved virtual address block entirely back to the OS.
Frees both the virtual address space and any committed physical RAM. All pointers into the released range become invalid immediately.
Example:
| ptr | Pointer returned by mem_os_reserve(). |
| size | Total size originally passed to mem_os_reserve(). |
Definition at line 50 of file mem_os.c.

| void * mem_os_reserve | ( | usize | size | ) |
Reserves a contiguous block of virtual address space.
Does not allocate physical RAM. The returned pointer cannot be read or written until mem_os_commit() is called on a sub-range.
Example:
| size | The size of the virtual address block to reserve. |
Definition at line 18 of file mem_os.c.
