hat-util 0.6.18
Utility library
allocator.h
Go to the documentation of this file.
1#ifndef HAT_ALLOCATOR_H
2#define HAT_ALLOCATOR_H
3
8#include <stddef.h>
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
15
28typedef void *(*hat_allocator_realloc_t)(hat_allocator_t *a, size_t size,
29 void *old);
30
40
41
49static inline void *hat_allocator_alloc(hat_allocator_t *a, size_t size) {
50 return a->realloc(a, size, NULL);
51}
52
61static inline void *hat_allocator_realloc(hat_allocator_t *a, size_t size,
62 void *old) {
63 return a->realloc(a, size, old);
64}
65
70static inline void hat_allocator_free(hat_allocator_t *a, void *old) {
71 a->realloc(a, 0, old);
72}
73
74#ifdef __cplusplus
75}
76#endif
77
78#endif
static void hat_allocator_free(hat_allocator_t *a, void *old)
Free memory block.
Definition allocator.h:70
static void * hat_allocator_realloc(hat_allocator_t *a, size_t size, void *old)
Reallocate existing memory block.
Definition allocator.h:61
static void * hat_allocator_alloc(hat_allocator_t *a, size_t size)
Allocate new memory block.
Definition allocator.h:49
void *(* hat_allocator_realloc_t)(hat_allocator_t *a, size_t size, void *old)
Custom allocator implementation function.
Definition allocator.h:28
Allocator base struct.
Definition allocator.h:36
hat_allocator_realloc_t realloc
custom realloc implementation
Definition allocator.h:38