Utility functions.


Functions

void ctl_set_allocator (void *(*realloc_func)(void *ctx, void *orig, size_t size), void(*free_func)(void *ctx, void *), void *ctx)
 Set the allocator that will be used by the library.
char * ctl_strdup (const char *orig)
 Duplicate the supplied string.
void * ctl_calloc (size_t nmemb, size_t size)
 Allocate and zero an array of elements.
void * ctl_malloc (size_t size)
 Allocate a chunk of memory.
void * ctl_realloc (void *orig, size_t size)
 Reallocate the supplied memory.
void ctl_free (void *block)
 Free the supplied memory block.

Function Documentation

void* ctl_calloc ( size_t  nmemb,
size_t  size 
)

Allocate and zero an array of elements.

Parameters:
nmemb - Number of elements
size - Size of each element
Returns:
The zeroed array

void ctl_free ( void *  block  ) 

Free the supplied memory block.

Parameters:
block - Memory block to release

void* ctl_malloc ( size_t  size  ) 

Allocate a chunk of memory.

Parameters:
size - Amount of memory to allocate
Returns:
The allocated memory

void* ctl_realloc ( void *  orig,
size_t  size 
)

Reallocate the supplied memory.

Parameters:
orig - The original memory block (may be NULL)
size - New size of the memory block
Returns:
The allocated memory

void ctl_set_allocator ( void *(*)(void *ctx, void *orig, size_t size)  realloc_func,
void(*)(void *ctx, void *)  free_func,
void *  ctx 
)

Set the allocator that will be used by the library.

Parameters:
realloc_func - Function for realloc() - this function MUST accept NULL as the original block parameter
free_func - Function for free()
ctx - User specified context that will be supplied to the allocator calls
By default the library will use the standard library allocation functions, you can use this function to redirect all memory usage by the library to a custom implementation. If you wish to use this functionality then you MUST call this function prior to any other calls into the Trading API.

The ctx parameter can be used to hold a reference to your memory pool/arena.

char* ctl_strdup ( const char *  orig  ) 

Duplicate the supplied string.

Parameters:
orig - The string to duplicate
Returns:
A duplicate of orig
This function will use the allocation routines set using sl_set_allocator() to duplicate the supplied string


Generated on Fri Aug 14 12:41:23 2015 for Trading API for C by  doxygen 1.5.3