aboutsummaryrefslogtreecommitdiff
path: root/allocator.h
diff options
context:
space:
mode:
authorThomas Schmucker <ts@its1.de>2022-01-16 11:29:59 +0100
committerThomas Schmucker <ts@its1.de>2022-01-16 11:29:59 +0100
commit1bb9e12dca59f6e97d14c938d37b9b492a9e546f (patch)
tree5100a6a48dd3da6c253eb3a81f3ba5560f84048f /allocator.h
parent85d7942c1c5c1b92add8a4dc70279e91b6f9cdaf (diff)
parent62b5acfcd5296a8f648716e7a51f00563be1668a (diff)
downloaddata-structures-1bb9e12dca59f6e97d14c938d37b9b492a9e546f.tar.gz
data-structures-1bb9e12dca59f6e97d14c938d37b9b492a9e546f.tar.bz2
data-structures-1bb9e12dca59f6e97d14c938d37b9b492a9e546f.zip
Merge branch 'cleanup/allocator'
Diffstat (limited to 'allocator.h')
-rw-r--r--allocator.h22
1 files changed, 11 insertions, 11 deletions
diff --git a/allocator.h b/allocator.h
index d47af52..dd9bb16 100644
--- a/allocator.h
+++ b/allocator.h
@@ -2,29 +2,29 @@
2 2
3#include <stddef.h> /* size_t */ 3#include <stddef.h> /* size_t */
4 4
5struct its1_allocator { 5struct allocator {
6 void *(*allocate)(struct its1_allocator *allocator, size_t n); 6 void *(*allocate)(struct allocator *allocator, size_t n);
7 void (*deallocate)(struct its1_allocator *allocator, void *ptr); 7 void (*deallocate)(struct allocator *allocator, void *ptr);
8}; 8};
9 9
10extern struct its1_allocator its1_default_allocator; 10extern struct allocator default_allocator;
11 11
12/* allocator interface */ 12/* allocator interface */
13void *its1_malloc(struct its1_allocator *allocator, size_t n); 13void *allocator_malloc(struct allocator *allocator, size_t n);
14void its1_free(struct its1_allocator *allocator, void *ptr); 14void allocator_free(struct allocator *allocator, void *ptr);
15 15
16/* helper functions */ 16/* helper functions */
17char *its1_strdup(struct its1_allocator *allocator, const char *str); 17char *allocator_strdup(struct allocator *allocator, const char *str);
18void *its1_malloc_zero(struct its1_allocator *allocator, size_t n); 18void *allocator_malloc_zero(struct allocator *allocator, size_t n);
19 19
20#define ALLOCATE(n) \ 20#define ALLOCATE(n) \
21 its1_malloc(&its1_default_allocator, (n)) 21 allocator_malloc(&allocator_default_allocator, (n))
22 22
23#define ALLOCATE_ZERO(n) \ 23#define ALLOCATE_ZERO(n) \
24 its1_malloc_zero(&its1_default_allocator, (n)) 24 allocator_malloc_zero(&allocator_default_allocator, (n))
25 25
26#define FREE(ptr) \ 26#define FREE(ptr) \
27 (its1_free(&its1_default_allocator, (ptr)), (ptr) = NULL) 27 (allocator_free(&allocator_default_allocator, (ptr)), (ptr) = NULL)
28 28
29#define NEW(ptr) ((ptr) = ALLOCATE(sizeof *(ptr))) 29#define NEW(ptr) ((ptr) = ALLOCATE(sizeof *(ptr)))
30#define NEW0(ptr) ((ptr) = ALLOCATE_ZERO(sizeof *(ptr))) 30#define NEW0(ptr) ((ptr) = ALLOCATE_ZERO(sizeof *(ptr)))