diff --git a/Docs/Allocator.md b/Docs/Allocator.md index d8116e7..559a370 100644 --- a/Docs/Allocator.md +++ b/Docs/Allocator.md @@ -35,9 +35,13 @@ Allocates memory on the heap and can zero the memory on allocation. void *hallocy_allocate(size_t size, bool zero_memory); ``` +**Args**: + - `size`: The amount of bytes to allocate. - `zero_memory`: Zero's memory when `true`. +**Returns**: Pointer to memory if successfull, else returns `NULL`. + ### Malloc Allocates memory on the heap. @@ -46,8 +50,12 @@ Allocates memory on the heap. static inline void *hallocy_malloc(size_t size) { return hallocy_allocate(size, false); } ``` +**Args**: + - `size`: The amount of bytes to allocate. +**Returns**: Pointer to memory if successfull, else returns `NULL`. + ### Calloc Allocates memory and zero's it on allocation. @@ -56,9 +64,13 @@ Allocates memory and zero's it on allocation. static inline void *hallocy_calloc(size_t size, size_t count) { return hallocy_allocate(size * count, true); } ``` +**Args**: + - `size`: Size of one element in bytes. - `count`: The amount of elements to allocate memory for. +**Returns**: Pointer to memory if successfull, else returns `NULL`. + ### Realloc Reallocates more memory for existing allocations. @@ -67,9 +79,13 @@ Reallocates more memory for existing allocations. void *hallocy_realloc(void *memory_pointer, size_t size); ``` +**Args**: + - `memory_pointer`: Pointer to already allocated heap memory. - `size`: The size of the new allocated memory. +**Returns**: Pointer to memory if successfull, else returns `NULL`. + ### Free Free's heap memory. @@ -78,8 +94,18 @@ Free's heap memory. HallocyError hallocy_free(void *pointer); ``` +**Args**: + - `pointer`: The pointer to allocated heap memory to free. +**Returns**: + +- **HALLOCY_ERROR_NONE**: Successfully freeed memory. +- **HALLOCY_ERROR_INVALID_PARAM**: Invalid parameters given. +- **HALLOCY_ERROR_OUT_OF_MEMORY**: System is out of memory. +- **HALLOCY_ERROR_INVALID_POINTER**: Invalid memory address given. +- **HALLOCY_ERROR_UNKNOWN**: Unknown error. + ## Example usage ```c