aboutsummaryrefslogtreecommitdiff
path: root/vec.c
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2025-07-22 08:59:24 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2025-07-22 08:59:24 +0200
commit13fdee74dc28f0b068503843c6e14071a7c339f2 (patch)
tree323f35e351394c89faeaf61cccad716ba4e4fb1a /vec.c
parente02bfc1854effe0bb55ea6d4320e2b1902eaeae3 (diff)
feat: More integer types
Diffstat (limited to 'vec.c')
-rw-r--r--vec.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/vec.c b/vec.c
index f555885..e91147e 100644
--- a/vec.c
+++ b/vec.c
@@ -4,10 +4,10 @@
#include "types.h"
#include "vec.h"
-Vec *_Vec_new(Arena *a, size tsize, size cap, int align) {
+Vec *_Vec_new(Arena *a, size tsize, size cap, size align) {
assert(cap > 0);
Vec *v = new(a, Vec, 1);
- v->size = tsize;
+ v->tsize = tsize;
v->cap = cap;
v->align = align;
v->len = 0;
@@ -17,12 +17,12 @@ Vec *_Vec_new(Arena *a, size tsize, size cap, int align) {
void Vec_push(Arena *a, Vec *v, void *data) {
if (v->len == v->cap) {
- void *cpy = alloc(a, v->cap * 2, v->size, v->align);
- memcpy(cpy, v->data, v->len * v->size);
+ void *cpy = alloc(a, v->cap * 2, v->tsize, v->align);
+ memcpy(cpy, v->data, v->len * v->tsize);
v->cap *= 2;
}
- memcpy(v->data + v->len * v->size, data, v->size);
+ memcpy(v->data + v->len * v->tsize, data, v->tsize);
v->len++;
}
-void *_Vec_get(Vec *v, int pos) { return v->data + v->size * pos; }
+void *_Vec_get(Vec *v, size pos) { return v->data + v->tsize * pos; }