Loading...
Searching...
No Matches
Allocator.h
Go to the documentation of this file.
/***************************************************************************************************
Zyan Core Library (Zycore-C)
Original Author : Florian Bernd
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
***************************************************************************************************/
#ifndef ZYCORE_ALLOCATOR_H
#define ZYCORE_ALLOCATOR_H
#include <Zycore/Status.h>
#include <Zycore/Types.h>
#ifdef __cplusplus
extern "C" {
#endif
/* ============================================================================================== */
/* Enums and types */
/* ============================================================================================== */
struct ZyanAllocator_;
typedef ZyanStatus (*ZyanAllocatorAllocate)(struct ZyanAllocator_* allocator, void** p,
ZyanUSize element_size, ZyanUSize n);
typedef ZyanStatus (*ZyanAllocatorDeallocate)(struct ZyanAllocator_* allocator, void* p,
ZyanUSize element_size, ZyanUSize n);
typedef struct ZyanAllocator_
{
ZyanAllocatorAllocate allocate;
ZyanAllocatorAllocate reallocate;
ZyanAllocatorDeallocate deallocate;
} ZyanAllocator;
/* ============================================================================================== */
/* Exported functions */
/* ============================================================================================== */
ZYCORE_EXPORT ZyanStatus ZyanAllocatorInit(ZyanAllocator* allocator, ZyanAllocatorAllocate allocate,
ZyanAllocatorAllocate reallocate, ZyanAllocatorDeallocate deallocate);
#ifndef ZYAN_NO_LIBC
ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanAllocator* ZyanAllocatorDefault(void);
#endif // ZYAN_NO_LIBC
/* ============================================================================================== */
#ifdef __cplusplus
}
#endif
#endif /* ZYCORE_ALLOCATOR_H */
ZyanAllocatorDefault
ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanAllocator * ZyanAllocatorDefault(void)
ZyanAllocatorAllocate
ZyanStatus(* ZyanAllocatorAllocate)(struct ZyanAllocator_ *allocator, void **p, ZyanUSize element_size, ZyanUSize n)
Definition Allocator.h:64
ZyanAllocatorDeallocate
ZyanStatus(* ZyanAllocatorDeallocate)(struct ZyanAllocator_ *allocator, void *p, ZyanUSize element_size, ZyanUSize n)
Definition Allocator.h:77
ZyanAllocatorInit
ZYCORE_EXPORT ZyanStatus ZyanAllocatorInit(ZyanAllocator *allocator, ZyanAllocatorAllocate allocate, ZyanAllocatorAllocate reallocate, ZyanAllocatorDeallocate deallocate)
ZyanAllocator
struct ZyanAllocator_ ZyanAllocator
ZYAN_REQUIRES_LIBC
#define ZYAN_REQUIRES_LIBC
Definition Defines.h:382
ZYCORE_EXPORT
#define ZYCORE_EXPORT
Definition Defines.h:244
Status.h
ZyanStatus
ZyanU32 ZyanStatus
Definition Status.h:48
Types.h
ZyanAllocator_
Definition Allocator.h:89
ZyanAllocator_::reallocate
ZyanAllocatorAllocate reallocate
Definition Allocator.h:97
ZyanAllocator_::deallocate
ZyanAllocatorDeallocate deallocate
Definition Allocator.h:101
ZyanAllocator_::allocate
ZyanAllocatorAllocate allocate
Definition Allocator.h:93