diff options
| author | Thomas Voss <mail@thomasvoss.com> | 2024-05-10 23:27:08 +0200 | 
|---|---|---|
| committer | Thomas Voss <mail@thomasvoss.com> | 2024-05-10 23:27:08 +0200 | 
| commit | 4f62899af7e97501ec081f9268d80ebf87150c2a (patch) | |
| tree | a06862b71cc319d1fe351b86995e115ebb550e85 /include | |
| parent | c0d2a0be9c95cc38818810207986818b333bc1de (diff) | |
Begin work on custom allocators in dynarr.h
Diffstat (limited to 'include')
| -rw-r--r-- | include/dynarr.h | 15 | 
1 files changed, 14 insertions, 1 deletions
| diff --git a/include/dynarr.h b/include/dynarr.h index 7edb035..52cacc5 100644 --- a/include/dynarr.h +++ b/include/dynarr.h @@ -3,9 +3,22 @@  #include <string.h> +#include "_alloc_fn.h"  #include "alloc.h" -#define dynarr(T) struct { T *buf; size_t len, cap; } +#define dynarr(T)                                                              \ +	struct {                                                                   \ +		T *buf;                                                                \ +		size_t len, cap;                                                       \ +		alloc_fn alloc;                                                        \ +		void *ctx;                                                             \ +	} + +void *dapush(void *, void *, size_t, size_t); + +#define dapush(da, ...)                                                        \ +	dapush((da), ((typeof(__VA_ARGS__)[1]){__VA_ARGS__}), sizeof(__VA_ARGS__), \ +	       alignof(__VA_ARGS__))  #define DAGROW(da, n)                                                          \  	do {                                                                       \ |