35#if defined(_WIN32) && !defined(__GNUC__)
37#define DETALLOC_API __declspec(dllexport)
39#define DETALLOC_API __declspec(dllimport)
42#define DETALLOC_API __attribute__((visibility("default")))
51#if defined(__GNUC__) || defined(__clang__)
52#define DET_INLINE static inline __attribute__((always_inline))
54#define DET_INLINE static inline
61#define DETALLOC_VERSION_MAJOR 0
62#define DETALLOC_VERSION_MINOR 1
63#define DETALLOC_VERSION_PATCH 0
69#ifndef DET_DEFAULT_BLOCK_SIZE
70#define DET_DEFAULT_BLOCK_SIZE 64
74#ifndef DET_DEFAULT_ALIGN
75#define DET_DEFAULT_ALIGN 8
80#define DET_ALIGN_UP(sz, a) (((sz) + ((a)-1)) & ~((a)-1))
240#define DET_NEW(alloc, type) ((type *)det_alloc((alloc)))
243#define DET_FREE(alloc, ptr) \
245 det_free((alloc), (ptr)); \
struct det_allocator det_allocator_t
Opaque allocator handle (single pool in Phase 1).
det_error_t
Error/status codes returned by Detalloc.
@ DET_ERR_NOT_INITIALIZED
DETALLOC_API void * det_alloc(det_allocator_t *alloc)
Allocate a single fixed-size block.
DETALLOC_API det_allocator_t * det_alloc_init(void *memory, size_t size, const det_config_t *config)
Initialize allocator over a user-provided memory buffer.
DETALLOC_API size_t det_alloc_size(const det_config_t *config)
Compute required buffer size for a given Phase-1 config.
DETALLOC_API det_config_t det_default_config(void)
Return a sensible Phase-1 default config.
DETALLOC_API const char * det_version_string(void)
Get library version string "major.minor.patch".
DETALLOC_API void det_alloc_destroy(det_allocator_t *alloc)
Destroy allocator structures (metadata cleanup only).
DETALLOC_API size_t det_alloc_usable_size(det_allocator_t *alloc, void *ptr)
Return usable size of a block.
DETALLOC_API void det_free(det_allocator_t *alloc, void *ptr)
Free a previously allocated block (NULL is a no-op).
DETALLOC_API void * det_calloc(det_allocator_t *alloc)
Allocate a zero-initialized block.
Phase-1 configuration: one fixed-size pool.