Quick 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>
Functions | |
kzsError | kzcMemoryManagerCreateQuickManager (const struct KzcMemoryManager *parentManager, kzSizeT size, struct KzcMemoryManager **out_memoryManager) |
Creates a new quick memory manager, which allocates the memory linearly from a preallocated chunk of memory. More... | |
kzBool | kzcMemoryIsQuickManager (const struct KzcMemoryManager *memoryManager) |
Checks whether the given memory manager is a quick memory manager or not. More... | |
kzsError | kzcMemoryManagerResetQuickManager (const struct KzcMemoryManager *memoryManager) |
Frees every pointer allocated with the given quick memory manager. More... | |
Quick memory manager.
The quick memory manager allocates memory from a constant-sized preallocated memory chunk in linear order. This manager type is optimized for speed and is intended for real-time memory allocation, such as temporary allocations for each rendering frame. The quick memory manager is not thread-safe.
The quick memory manager does not have complicated internal bookkeeping structures, it simply keeps a pointer to the last allocated block and satisfies any following allocation by assigning it space directly following the last allocated block. Deallocation of individual blocks is not supported at all. This means that this memory manager is prone to memory fragmentation and should not be used for other than temporary allocations. Every time the current allocated chunk of memory runs out, the quick memory manager allocates another one of roughly the same size (or the requested size in the case it is larger than the current chunk's size).
Since the quick memory manager does not support deallocation of individual pointers, the whole chunk of memory must be deallocated at once using kzcMemoryManagerResetQuickManager(). Notice that this will invalidate all memory allocated with the same quick memory manager.
Copyright 2008-2017 by Rightware. All rights reserved.
kzsError kzcMemoryManagerCreateQuickManager | ( | const struct KzcMemoryManager * | parentManager, |
kzSizeT | size, | ||
struct KzcMemoryManager ** | out_memoryManager | ||
) |
Creates a new quick memory manager, which allocates the memory linearly from a preallocated chunk of memory.
See the top of this file for more information on the quick memory manager.
parentManager | The memory manager that is used for allocating the memory chunks. This can be e.g. a system memory manager (kzc_memory_system.h). |
size | Size of the initial memory chunk. |
out_memoryManager | A pointer that is set to point to the new quick manager manager on success. |
kzBool kzcMemoryIsQuickManager | ( | const struct KzcMemoryManager * | memoryManager | ) |
kzsError kzcMemoryManagerResetQuickManager | ( | const struct KzcMemoryManager * | memoryManager | ) |
Frees every pointer allocated with the given quick memory manager.
memoryManager | A valid quick memory manager. |