From 3a81615601bf37ffc4f7b570030709ac0782e2ed Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 10 Aug 2026 09:18:23 +0000 Subject: Avoid calling malloc/free in the library code. FossilOrigin-Name: 3e7c2c1b4beda2a729c880caf1a41c441e0a8387d40b666ac7163eb1346653b5 --- src/aplwc_internal.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/aplwc_internal.h') diff --git a/src/aplwc_internal.h b/src/aplwc_internal.h index f80c8ab..ccf600f 100644 --- a/src/aplwc_internal.h +++ b/src/aplwc_internal.h @@ -1,6 +1,8 @@ #ifndef APLWC_INTERNAL_H #define APLWC_INTERNAL_H +#include + #define UNUSED_PARAMETER(arg) ((void)arg) #define RETURN_ERROR(aplwc, rc, msg) do{ \ @@ -12,21 +14,32 @@ #define NELEM(x) (sizeof(x)/sizeof(x[0])) -#include -#include +#include +#include #include #include #include +typedef struct Memory Memory; + +struct Memory { + uint8_t *data; + size_t size; + size_t offset; +}; + struct Aplwc { AplwcRc last_error; char last_error_msg[64]; + Memory memory; }; /* errors.c */ const char *rc_to_string(AplwcRc); -/* malloc.c */ -void *malloc_zero(size_t); +/* memory.c */ +Memory memory_init(uint8_t *, size_t); +Aplwc *memory_alloc_aplwc(Memory *); +void memory_free_aplwc(Memory *, Aplwc *); #endif /* APLWC_INTERNAL_H */ -- cgit v1.2.3