docs(allocator): added return type to functions in allocator docs

This commit is contained in:
Mineplay 2025-04-19 08:59:31 -05:00
parent 436594ae67
commit 89f8f2b5c4

View file

@ -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); void *hallocy_allocate(size_t size, bool zero_memory);
``` ```
**Args**:
- `size`: The amount of bytes to allocate. - `size`: The amount of bytes to allocate.
- `zero_memory`: Zero's memory when `true`. - `zero_memory`: Zero's memory when `true`.
**Returns**: Pointer to memory if successfull, else returns `NULL`.
### Malloc ### Malloc
Allocates memory on the heap. 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); } static inline void *hallocy_malloc(size_t size) { return hallocy_allocate(size, false); }
``` ```
**Args**:
- `size`: The amount of bytes to allocate. - `size`: The amount of bytes to allocate.
**Returns**: Pointer to memory if successfull, else returns `NULL`.
### Calloc ### Calloc
Allocates memory and zero's it on allocation. 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); } 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. - `size`: Size of one element in bytes.
- `count`: The amount of elements to allocate memory for. - `count`: The amount of elements to allocate memory for.
**Returns**: Pointer to memory if successfull, else returns `NULL`.
### Realloc ### Realloc
Reallocates more memory for existing allocations. 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); void *hallocy_realloc(void *memory_pointer, size_t size);
``` ```
**Args**:
- `memory_pointer`: Pointer to already allocated heap memory. - `memory_pointer`: Pointer to already allocated heap memory.
- `size`: The size of the new allocated memory. - `size`: The size of the new allocated memory.
**Returns**: Pointer to memory if successfull, else returns `NULL`.
### Free ### Free
Free's heap memory. Free's heap memory.
@ -78,8 +94,18 @@ Free's heap memory.
HallocyError hallocy_free(void *pointer); HallocyError hallocy_free(void *pointer);
``` ```
**Args**:
- `pointer`: The pointer to allocated heap memory to free. - `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 ## Example usage
```c ```c