Core memory manager. More...
#include <kanzi/core/legacy/memory/kzc_memory_common.hpp>
#include <kanzi/core/legacy/kzs_types.hpp>
#include <kanzi/core/legacy/debug/kzs_error.hpp>
Macros | |
#define | KZC_MEMORY_MANAGER_SIZE_UNSPECIFIED |
Constant for memory manager size that's unspecified. More... | |
#define | kzcMemoryAllocPointer(manager_param, pointer_param, size_param, description_param) |
Allocates arbitrary memory pointer using the given memory manager. More... | |
#define | kzcMemoryAllocArray(manager_param, array_param, length_param, description_param) |
Allocates array of arbitrary type using the given memory manager. More... | |
#define | kzcMemoryAllocVariable(manager_param, variable_param, description_param) |
Allocates an object of arbitrary type using the given memory manager. More... | |
Functions | |
KANZI_API kzsError | kzcMemoryManagerDelete (struct KzcMemoryManager *memoryManager) |
Frees the memory allocated for a memory manager. More... | |
KANZI_API kzsError | kzcMemoryAllocPointer_private (const struct KzcMemoryManager *memoryManager, kzSizeT size, void **out_pointer MEMORY_MANAGER_DEBUG_PARAM_PRIVATE(kzString description)) |
KANZI_API kzsError | kzcMemoryAllocArray_private (const struct KzcMemoryManager *memoryManager, kzUint length, kzSizeT elementSize, void **out_array MEMORY_MANAGER_DEBUG_PARAM_PRIVATE(kzString description)) |
kzsError | kzcMemoryReallocPointer (void *pointer, kzSizeT oldSize, kzSizeT newSize, void **out_newPointer) |
Reallocates arbitrary memory pointer to the given new size. More... | |
KANZI_API kzsError | kzcMemoryFreePointer (void *pointer) |
Frees an arbitrary pointer from memory manager. More... | |
KANZI_API kzsError | kzcMemoryFreeArray (void *array) |
Frees an array from memory manager. More... | |
KANZI_API kzsError | kzcMemoryFreeVariable (void *variable) |
Frees a variable from memory manager. More... | |
KANZI_API kzBool | kzcIsValidPointer (const void *pointer) |
Checks if the given pointer is valid. More... | |
kzBool | kzcIsValidArrayIndex (const void *array, kzUint index) |
Checks if the given index is valid for the given array. More... | |
kzU32 | kzcMemoryCalculateChecksum (const void *pointer) |
Calculates a checksum of the given pointer. More... | |
KANZI_API struct KzcMemoryManager * | kzcMemoryGetManager (const void *pointer) |
Gets the memory manager responsible of the given pointer. More... | |
KANZI_API kzUint | kzcArrayLength (const void *array) |
Returns the length of an array. More... | |
enum KzcMemoryManagerType | kzcMemoryManagerGetType (const struct KzcMemoryManager *memoryManager) |
Gets memory manager type. More... | |
kzSizeT | kzcMemoryManagerGetSize (const struct KzcMemoryManager *memoryManager) |
Gets size of memory manager in bytes. More... | |
Core memory manager.
Memory managers provide memory allocation and deallocation functionality. This header file provides the common interface for all Kanzi memory managers. There are four different types of Kanzi memory managers: system, pooled, quick and custom. The custom type provides a way to implement your own memory manager. See kzc_memory_system.h, kzc_memory_quick.h and kzc_memory_custom.h for descriptions of each of them.
Copyright 2008-2017 by Rightware. All rights reserved.
#define KZC_MEMORY_MANAGER_SIZE_UNSPECIFIED |
Constant for memory manager size that's unspecified.
#define kzcMemoryAllocPointer | ( | manager_param, | |
pointer_param, | |||
size_param, | |||
description_param | |||
) |
Allocates arbitrary memory pointer using the given memory manager.
#define kzcMemoryAllocArray | ( | manager_param, | |
array_param, | |||
length_param, | |||
description_param | |||
) |
Allocates array of arbitrary type using the given memory manager.
#define kzcMemoryAllocVariable | ( | manager_param, | |
variable_param, | |||
description_param | |||
) |
Allocates an object of arbitrary type using the given memory manager.
KANZI_API kzsError kzcMemoryManagerDelete | ( | struct KzcMemoryManager * | memoryManager | ) |
Frees the memory allocated for a memory manager.
KANZI_API kzsError kzcMemoryAllocPointer_private | ( | const struct KzcMemoryManager * | memoryManager, |
kzSizeT | size, | ||
void **out_pointer | MEMORY_MANAGER_DEBUG_PARAM_PRIVATEkzString description | ||
) |
KANZI_API kzsError kzcMemoryAllocArray_private | ( | const struct KzcMemoryManager * | memoryManager, |
kzUint | length, | ||
kzSizeT | elementSize, | ||
void **out_array | MEMORY_MANAGER_DEBUG_PARAM_PRIVATEkzString description | ||
) |
kzsError kzcMemoryReallocPointer | ( | void * | pointer, |
kzSizeT | oldSize, | ||
kzSizeT | newSize, | ||
void ** | out_newPointer | ||
) |
Reallocates arbitrary memory pointer to the given new size.
This function behaves differently from C realloc function such that the given pointer may not be KZ_NULL and the function never returns KZ_NULL in case of success. The function returns a pointer containing the data of the given pointer up to the length of min(newSize, old size). The old pointer is freed if new memory was allocated.
Frees an arbitrary pointer from memory manager.
Checks if the given index is valid for the given array.
kzU32 kzcMemoryCalculateChecksum | ( | const void * | pointer | ) |
Calculates a checksum of the given pointer.
This value can later be used for checking if the memory content has been modified.
KANZI_API struct KzcMemoryManager* kzcMemoryGetManager | ( | const void * | pointer | ) |
Gets the memory manager responsible of the given pointer.
enum KzcMemoryManagerType kzcMemoryManagerGetType | ( | const struct KzcMemoryManager * | memoryManager | ) |
Gets memory manager type.
kzSizeT kzcMemoryManagerGetSize | ( | const struct KzcMemoryManager * | memoryManager | ) |
Gets size of memory manager in bytes.
Returns KZC_MEMORY_MANAGER_SIZE_NOT_SPECIFIED if not specified.