DelegateMQ
Loading...
Searching...
No Matches
xallocator.h File Reference
#include <cstdint>
#include <stddef.h>

Go to the source code of this file.

Functions

void xalloc_init ()
 
void xalloc_destroy ()
 
void * xmalloc (size_t size)
 
void xfree (void *ptr)
 
void * xrealloc (void *ptr, size_t size)
 
void xalloc_stats ()
 Output allocator statistics to the standard output.
 

Function Documentation

◆ xalloc_destroy()

void xalloc_destroy ( )

This function must be called once when the application exits. Never call xalloc_destroy() manually except if using xallocator in a C-only application. If using xallocator exclusively in C files within your application code, you must call this function before the program exits. If using C++, ~XallocInitDestroy() must call xalloc_destroy automatically. Embedded systems that never exit need not call this function at all.

Called one time when the application exits to cleanup any allocated memory. ~XallocInitDestroy destructor calls this function automatically.

◆ xalloc_init()

void xalloc_init ( )

This function must be called exactly one time before the operating system threading starts. If using xallocator exclusively in C files within your application code, you must call this function before the OS starts. If using C++, client code does not call xalloc_init. Let XallocInitDestroy() call xalloc_init automatically. Embedded systems that never exit can call xalloc_init() manually at startup and eliminate XallocInitDestroy usage. When the system is still single threaded at startup, the xallocator API does not need mutex protection.

This function must be called exactly one time before any other xallocator API is called. XallocInitDestroy constructor calls this function automatically.

◆ xalloc_stats()

void xalloc_stats ( )

Output allocator statistics to the standard output.

Output allocator statistics to the standard output.

◆ xfree()

void xfree ( void * ptr)

Frees a previously xalloc allocated block

Parameters
[in]ptr- a pointer to a previously allocated memory using xalloc.

Frees a memory block previously allocated with xalloc. The blocks are returned to the fixed block allocator that originally created it.

Parameters
[in]ptr- a pointer to a block created with xalloc.

◆ xmalloc()

void * xmalloc ( size_t size)

Allocate a block of memory

Parameters
[in]size- the size of the block to allocate.

Allocates a memory block of the requested size. The blocks are created from the fixed block allocators.

Parameters
[in]size- the client requested size of the block.
Returns
A pointer to the client's memory block.

◆ xrealloc()

void * xrealloc ( void * oldMem,
size_t size )

Reallocates an existing xalloc block to a new size

Parameters
[in]ptr- a pointer to a previously allocated memory using xalloc.
[in]size- the size of the new block

Reallocates a memory block previously allocated with xalloc.

Parameters
[in]ptr- a pointer to a block created with xalloc.
[in]size- the client requested block size to create.