summaryrefslogtreecommitdiff
path: root/src/aplwc_internal.h
diff options
context:
space:
mode:
authorpeter <peter@pmikkelsen.com>2026-08-10 09:18:23 +0000
committerpeter <peter@pmikkelsen.com>2026-08-10 09:18:23 +0000
commit3a81615601bf37ffc4f7b570030709ac0782e2ed (patch)
treefc5a4d59b9bb62521d37a878c1fa7bb34d3d2bb5 /src/aplwc_internal.h
parente30299f2cd59c46c2d733e38139da96c93f9acf4 (diff)
Avoid calling malloc/free in the library code.
FossilOrigin-Name: 3e7c2c1b4beda2a729c880caf1a41c441e0a8387d40b666ac7163eb1346653b5
Diffstat (limited to 'src/aplwc_internal.h')
-rw-r--r--src/aplwc_internal.h21
1 files changed, 17 insertions, 4 deletions
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 <aplwc.h>
+
#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 <stddef.h>
-#include <stdint.h>
+#include <stdalign.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+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 */