liballoc-c

C generic allocator interface
git clone https://git.sinitax.com/sinitax/liballoc-c
Log | Files | Refs | LICENSE | sfeed.txt

commit b93172a2d59ff5c939bb58dd902c0db65efba8b6
parent fa03741cf151f639e361b556f9e60d1925f41d42
Author: Louis Burda <quent.burda@gmail.com>
Date:   Sun, 21 May 2023 21:18:01 +0200

Make stdlib allocator structs const

Diffstat:
Minclude/allocator.h | 4++--
Msrc/allocator.c | 4++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/allocator.h b/include/allocator.h @@ -10,5 +10,5 @@ struct allocator { int (*free)(const struct allocator *allocator, void *p); }; -extern struct allocator stdlib_heap_allocator; -extern struct allocator stdlib_strict_heap_allocator; +extern const struct allocator stdlib_heap_allocator; +extern const struct allocator stdlib_strict_heap_allocator; diff --git a/src/allocator.c b/src/allocator.c @@ -15,13 +15,13 @@ static void *stdlib_strict_heap_realloc(const struct allocator *allocator, void *p, size_t size, int *rc); static int stdlib_strict_heap_free(const struct allocator *allocator, void *p); -struct allocator stdlib_heap_allocator = { +const struct allocator stdlib_heap_allocator = { .alloc = stdlib_heap_alloc, .realloc = stdlib_heap_realloc, .free = stdlib_heap_free }; -struct allocator stdlib_strict_heap_allocator = { +const struct allocator stdlib_strict_heap_allocator = { .alloc = stdlib_strict_heap_alloc, .realloc = stdlib_strict_heap_realloc, .free = stdlib_strict_heap_free