diff options
author | Nicholas Noll <nbnoll@eml.cc> | 2021-12-10 09:16:08 -0800 |
---|---|---|
committer | Nicholas Noll <nbnoll@eml.cc> | 2021-12-10 09:16:08 -0800 |
commit | 25537c3d3b9b68af91573dec39d1f46c3d97f735 (patch) | |
tree | 3f2ea6207a28fe9610d767dd78fb24d17f858ce0 /include/base/memory.h | |
parent | f4aef385bdd41b02ef58b5366fa9318ecdc6e37e (diff) |
Checkin: small sprawling updates
Small touches to multiple locations in base.
Nothing major
Diffstat (limited to 'include/base/memory.h')
-rw-r--r-- | include/base/memory.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/include/base/memory.h b/include/base/memory.h index 6bf3cbc..a97615e 100644 --- a/include/base/memory.h +++ b/include/base/memory.h @@ -31,6 +31,7 @@ typedef struct mem·BufHead #define mem·buffree(b) ((b) ? (free(mem·bufhdr(b)), (b) = nil) : 0) #define mem·buffit(b, n) ((n) <= mem·bufcap(b) ? 0 : ((b) = mem·bufgrow((b), (n), sizeof(*(b))))) +#define mem·bufreset(b) ((b) ? (mem·bufhdr(b)->len=0) : 0) #define mem·bufpush(b, ...) (mem·buffit((b), 1 + mem·buflen(b)), (b)[mem·bufhdr(b)->len++] = (__VA_ARGS__)) #define mem·bufaddn(b, n) (mem·buffit(b, mem·buflen(b)+n), mem·bufhdr(b)->len += n, b+mem·bufhdr(b)->len-n) @@ -50,8 +51,8 @@ typedef struct mem·Pool mem·Pool; typedef struct mem·Arena mem·Arena; typedef struct mem·Allocator { - void *(*alloc)(void *heap, long n, uintptr size); - void *(*realloc)(void *heap, void *ptr, long n, uintptr size); + void *(*alloc)(void *heap, uintptr n, uintptr size); + void *(*realloc)(void *heap, void *ptr, uintptr n, uintptr size); void (*free)(void *heap, void *ptr); } mem·Allocator; |