thistle-sdk
Thistle SDK documentation
Loading...
Searching...
No Matches
mallocng.h File Reference
#include <stdint.h>

Go to the source code of this file.

Functions

const char * tma_get_name (void)
 
void * tma_malloc (size_t size)
 
void tma_free (void *ptr)
 
void * tma_realloc (void *ptr, size_t size)
 
void * tma_calloc (size_t nmemb, size_t size)
 
void * tma_valloc (uintptr_t size)
 
void * tma_memalign (uintptr_t alignment, uintptr_t size)
 
uintptr_t tma_malloc_usable_size (void *ptr)
 
void * musl_malloc (size_t size)
 
void musl_free (void *ptr)
 
void * musl_realloc (void *ptr, uintptr_t size)
 
void * musl_calloc (uintptr_t nmemb, uintptr_t size)
 
void * musl_valloc (uintptr_t size)
 
void * musl_memalign (uintptr_t alignment, uintptr_t size)
 
uintptr_t musl_malloc_usable_size (void *ptr)
 

Function Documentation

◆ musl_calloc()

void * musl_calloc ( uintptr_t  nmemb,
uintptr_t  size 
)

◆ musl_free()

void musl_free ( void *  ptr)

◆ musl_malloc()

void * musl_malloc ( size_t  size)

◆ musl_malloc_usable_size()

uintptr_t musl_malloc_usable_size ( void *  ptr)

◆ musl_memalign()

void * musl_memalign ( uintptr_t  alignment,
uintptr_t  size 
)

◆ musl_realloc()

void * musl_realloc ( void *  ptr,
uintptr_t  size 
)

◆ musl_valloc()

void * musl_valloc ( uintptr_t  size)

◆ tma_calloc()

void * tma_calloc ( size_t  nmemb,
size_t  size 
)

Allocates memory for an array of nmemb elements of size bytes each and returns a pointer to the allocated memory. The memory is set to zero. If nmemb or sizeis 0, then tma_calloc() returns either NULL, or a unique pointer value that can later be successfully passed to tma_free(). If the multiplication of nmemb and size would result in integer overflow, then tma_calloc() returns an error. By contrast, an integer overflow would not be detected in the following call to tma_malloc(), with the result that an incorrectly sized block of memory would be allocated.

Parameters
nmembThe number of elements to be allocated
sizeThe size of each element.
Returns
A pointer to the allocated memory or NULL on failure.

◆ tma_free()

void tma_free ( void *  ptr)

Deallocates the memory pointed to by ptr which must have been returned by a previous call to tma_malloc(), tma_calloc(), or tma_realloc(), otherwise undefinied behavior may occur. If the underlying allocator support detection of double or invalid frees this function may abort.

Parameters
ptrA pointer to the memory returned from a call to tma_malloc, tma_calloc, or tma_realloc.

◆ tma_get_name()

const char * tma_get_name ( void  )

Return a pointer to a statically allocated string containing the internal name of the allocator.

Returns
Pointer to a statically allocated string. Do not free or change.

◆ tma_malloc()

void * tma_malloc ( size_t  size)

Allocate size bytes and return a pointer to the allocated memory. The memory is not initialized. If size is 0 then this function returns either NULL or a unique pointer value that can be passed to tma_free().

Parameters
sizeSize of the memory block in bytes.
Returns
A pointer to the allocated memory or NULL on failure.

◆ tma_malloc_usable_size()

uintptr_t tma_malloc_usable_size ( void *  ptr)

◆ tma_memalign()

void * tma_memalign ( uintptr_t  alignment,
uintptr_t  size 
)

◆ tma_realloc()

void * tma_realloc ( void *  ptr,
size_t  size 
)

Change the size of the memory block pointed to by ptr to size bytes. The contents will be unchanged in the range from the start of the region up to the minimum of the old and new sizes. If the new size is larger than the old size the added memory will not be initialized. If ptr is NULL, then the call is equivalent to tma_malloc(size), for all values of size; if size is equal to zero, and ptr is not NULL, then the call is equivalent to tma_free(ptr) Unless ptr is NULL, it must have been returned by an earlier call to tma_malloc(), tma_calloc(), or tma_realloc(). If the area pointed to was moved, a tma_free(ptr) is done.

Parameters
ptrA pointer to the memory returned from a call to tma_malloc, tma_calloc, or tma_realloc. If this value is NULL a new block will be allocated.
sizeNew size of the memory block in bytes.
Returns
A pointer to the newly allocated memory or NULL on failure.If it is 0 and ptr points to an existing block of memory, the memory block pointed by ptr is deallocated and a NULL pointer is returned.

◆ tma_valloc()

void * tma_valloc ( uintptr_t  size)