aboutsummaryrefslogtreecommitdiff
path: root/vec.h
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2025-01-31 08:02:09 +0100
committerMartin Kagamino Lehoux <martin@lehoux.net>2025-01-31 08:02:09 +0100
commit8a9e6b1bd3be1041792311a86d8aac68b659e891 (patch)
tree2a62729da17b2e6669c3d71a162525ff37e42c6a /vec.h
feat: First version, failing json parse string
Diffstat (limited to 'vec.h')
-rw-r--r--vec.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/vec.h b/vec.h
new file mode 100644
index 0000000..9fb9590
--- /dev/null
+++ b/vec.h
@@ -0,0 +1,20 @@
+#include <stddef.h>
+#include <stdint.h>
+
+#include "memory.h"
+
+#ifndef VEC_H
+#define VEC_H
+typedef struct {
+ void *data;
+ ptrdiff_t len;
+ ptrdiff_t cap;
+ uintptr_t size;
+ int align;
+} Vec;
+#define Vec_new(a, T, cap) _Vec_new(a, sizeof(T), cap, _Alignof(T))
+Vec *_Vec_new(Arena *a, int size, ptrdiff_t cap, int align);
+Vec *Vec_push(Arena *a, Vec *v, void *data);
+#define Vec_get(v, T, p) (T *)_Vec_get(v, p)
+void *_Vec_get(Vec *v, int pos);
+#endif