All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
kzc_memory_custom.h File Reference

Custom memory manager. More...

Typedefs

typedef kzsError(* KzcMemoryAllocFunction )(void *customData, kzSizeT size, void **out_pointer)
 Memory allocation function type. More...
 
typedef kzsError(* KzcMemoryFreeFunction )(void *customData, void *pointer)
 Memory deallocation function type. More...
 

Functions

kzsError kzcMemoryManagerCreateCustomManager (KzcMemoryAllocFunction allocator, KzcMemoryFreeFunction deallocator, void *customData, struct KzcMemoryManager **out_memoryManager)
 Creates a new memory manager, which allocates the memory with custom memory allocation functions. More...
 

Detailed Description

Custom memory manager.

Custom memory manager provides a way to plug in arbitrary memory allocation mechanisms. A custom Kanzi memory manager can be created with kzcMemoryManagerCreateCustomManager() by passing your own allocation and deallocation functions.

Copyright 2008-2020 by Rightware. All rights reserved.

Typedef Documentation

typedef kzsError(* KzcMemoryAllocFunction)(void *customData, kzSizeT size, void **out_pointer)

Memory allocation function type.

Used for custom memory managers.

Parameters
customDataThe customData pointer passed to kzcMemoryManagerCreateCustomManager().
sizeRequested number of bytes to allocate.
out_pointerA pointer that should be set to point to the beginning of the allocated memory area.
Returns
The function should return KZS_SUCCESS on success.
typedef kzsError(* KzcMemoryFreeFunction)(void *customData, void *pointer)

Memory deallocation function type.

Used for custom memory managers.

Parameters
customDataThe customData pointer passed to kzcMemoryManagerCreateCustomManager().
pointerPointer to the beginning of the memory area to free.
Returns
The function should return KZS_SUCCESS on success.

Function Documentation

kzsError kzcMemoryManagerCreateCustomManager ( KzcMemoryAllocFunction  allocator,
KzcMemoryFreeFunction  deallocator,
void *  customData,
struct KzcMemoryManager **  out_memoryManager 
)

Creates a new memory manager, which allocates the memory with custom memory allocation functions.

Parameters
allocatorMemory allocation function to call when memory is allocated with this memory manager.
deallocatorMemory deallocation function to call when memory is freed with this memory manager.
customDataArbitrary pointer passed to the allocator and deallocator functions.
out_memoryManagerA pointer that is set to point to the new memory manager on success.
Returns
KZS_SUCCESS on success.