Lightweight layer between platform and other engine components to enable tracing/monitoring.
More...
Go to the source code of this file.
|
#define | KB_KILOBYTE(n) (n * 1024) |
|
#define | KB_MEGABYTE(n) KB_KILOBYTE(KB_KILOBYTE(n)) |
|
#define | KB_GIGABYTE(n) KB_KILOBYTE(KB_MEGABYTE(n)) |
|
|
KB_LOCAL b8 | memory_initialize (void) |
|
KB_LOCAL void * | memory_page_allocate (usize target_num_bytes, usize *res_num_bytes) |
|
KB_LOCAL void | memory_page_free (void *page_data) |
|
KB_LOCAL void | memory_shutdown (void) |
|
KB_API void * | memory_allocate (usize size) |
| Allocate memory. More...
|
|
KB_API void | memory_free (void *mem, usize size) |
| Free memory. More...
|
|
KB_API void * | memory_zero (void *mem, usize size) |
| Zero out memory. More...
|
|
KB_API void * | memory_set (void *mem, u8 byte, usize size) |
| Set content of memory block. More...
|
|
KB_API void * | memory_copy (void *dst, const void *src, usize size) |
| Copy memory. More...
|
|
KB_API void * | memory_aligned_address (void *addr, usize alignment) |
| Calculate properly aligned memory block address. More...
|
|
Lightweight layer between platform and other engine components to enable tracing/monitoring.
Definition in file memory.h.
◆ memory_aligned_address()
KB_API void* memory_aligned_address |
( |
void * |
addr, |
|
|
usize |
alignment |
|
) |
| |
Calculate properly aligned memory block address.
Calculate a new address which is a multiple of the alignment provided. At most alignment bytes above provided address.
- Parameters
-
addr | original memory block addr |
alignment | number of bytes to be aligned by |
- Returns
- aligned new address
Definition at line 85 of file memory.c.
◆ memory_allocate()
KB_API void* memory_allocate |
( |
usize |
size | ) |
|
Allocate memory.
- Parameters
-
size | number of bytes to be allocated |
- Returns
- pointer to beginning of allocated block (zeroed out)
Definition at line 72 of file memory.c.
◆ memory_copy()
KB_API void* memory_copy |
( |
void * |
dst, |
|
|
const void * |
src, |
|
|
usize |
size |
|
) |
| |
Copy memory.
- Parameters
-
dst | pointer to beginning of the destination memory block |
src | pointer to beginning of the source memory block |
size | number of bytes to be copied |
- Returns
- pointer to beginning of the destination block
Definition at line 83 of file memory.c.
◆ memory_free()
KB_API void memory_free |
( |
void * |
mem, |
|
|
usize |
size |
|
) |
| |
Free memory.
- Parameters
-
mem | pointer to beginning of memory block |
size | number of bytes to be freed |
Definition at line 77 of file memory.c.
◆ memory_set()
KB_API void* memory_set |
( |
void * |
mem, |
|
|
u8 |
byte, |
|
|
usize |
size |
|
) |
| |
Set content of memory block.
- Parameters
-
mem | pointer to beginning of memory block |
byte | the value to set every byte to |
size | number of bytes to be set |
- Returns
- pointer to beginning of the block
Definition at line 81 of file memory.c.
◆ memory_zero()
KB_API void* memory_zero |
( |
void * |
mem, |
|
|
usize |
size |
|
) |
| |
Zero out memory.
- Parameters
-
mem | pointer to beginning of memory block |
size | number of bytes to be zeroed out |
- Returns
- pointer to beginning of zeroed block
Definition at line 79 of file memory.c.