Zen API
 All Classes Files Functions Variables Typedefs Macros Groups Pages
kApiLib.h File Reference

Description

Zen API library management functions.

Go to the source code of this file.

Typedefs

typedef kStatus(kCallkApiMemAllocFx )(kPointer provider, kSize size, void *mem)
 Function signature for memory allocation handler. More...
 
typedef kStatus(kCallkApiMemFreeFx )(kPointer provider, void *mem)
 Function signature for memory free handler. More...
 

Functions

kStatus kApiLib_Construct (kAssembly *assembly)
 Constructs the Zen API type assembly (kApiLib). More...
 
kStatus kApiLib_SetMemAllocHandlers (kApiMemAllocFx allocFx, kApiMemFreeFx freeFx, kPointer provider)
 Sets handler functions for memory alloc/free operations. More...
 

Typedef Documentation

typedef kStatus(kCall* kApiMemAllocFx)(kPointer provider, kSize size, void *mem)

Function signature for memory allocation handler.

typedef kStatus(kCall* kApiMemFreeFx)(kPointer provider, void *mem)

Function signature for memory free handler.

Function Documentation

kStatus kApiLib_Construct ( kAssembly assembly)

Constructs the Zen API type assembly (kApiLib).

This function initializes the Zen API assembly and returns a handle that represents the assembly. When the assembly is no longer needed, pass the assembly handle to the kObject_Destroy function.

This function should be called prior to calling most other Zen API functions. The only exceptions to this rule are kApiLib functions that configure global handlers (e.g. kApiLib_SetMemAllocHandlers); these functions should typically be called prior to kApiLib_Construct.

Multiple nested calls to this function will return the same assembly instance. To ensure final clean up, the kObject_Destroy function should be invoked a corresponding number of times on the assembly handle.

Parameters
assemblyReceives a handle to the kApiLib type assembly.
Returns
Operation status.
kStatus kApiLib_SetMemAllocHandlers ( kApiMemAllocFx  allocFx,
kApiMemFreeFx  freeFx,
kPointer  provider 
)

Sets handler functions for memory alloc/free operations.

By default, kApiLib uses C standard library functions for memory allocation. Call this function to override the default behaviour.

This function is not thread-safe and should be called before calling kApiLib_Construct.

Parameters
allocFxMemory allocation callback function.
freeFxMemory deallocation callback function.
providerContext pointer (provided to callback functions).
Returns
Operation status.