Helium
Functions
memory.h File Reference

Customisation of allocators if desired. More...

#include "he.h"
#include "he_internal.h"
Include dependency graph for memory.h:

Go to the source code of this file.

Functions

he_return_code_t he_set_allocators (he_malloc_t malloc, he_calloc_t calloc, he_realloc_t realloc, he_free_t free)
 Set allocators for use by libhelium. More...
 
void * he_malloc (size_t size)
 Allocate memory using the internal malloc function set by he_set_allocators() More...
 
void * he_calloc (size_t nmemb, size_t size)
 Allocate memory using the internal calloc function set by he_set_allocators() More...
 
void * he_realloc (void *ptr, size_t size)
 Allocate memory using the internal realloc function set by he_set_allocators() More...
 
void he_free (void *ptr)
 Free memory using the internal free function set by he_set_allocators()
 

Detailed Description

Customisation of allocators if desired.

Function Documentation

◆ he_calloc()

void* he_calloc ( size_t  nmemb,
size_t  size 
)

Allocate memory using the internal calloc function set by he_set_allocators()

Note
The caller must call he_free when the allocated memory is no longer used

◆ he_malloc()

void* he_malloc ( size_t  size)

Allocate memory using the internal malloc function set by he_set_allocators()

Note
The caller must call he_free when the allocated memory is no longer used

◆ he_realloc()

void* he_realloc ( void *  ptr,
size_t  size 
)

Allocate memory using the internal realloc function set by he_set_allocators()

Note
The caller must call he_free when the allocated memory is no longer used

◆ he_set_allocators()

he_return_code_t he_set_allocators ( he_malloc_t  malloc,
he_calloc_t  calloc,
he_realloc_t  realloc,
he_free_t  free 
)

Set allocators for use by libhelium.

Parameters
mallocA function that conforms to the signature of malloc(3)
callocA function that conforms to the signature of calloc(3)
reallocA function that conforms to the signature of realloc(3)
freeA function that conforms to the signature of free(3)
Returns
HE_SUCCESS Currently this function cannot fail
Note
If this function is not called, Helium will use system allocators by default