#ifndef APFL_RESIZABLE #define APFL_RESIZABLE 1 #include #include #include "apfl.h" // TODO: Find a way to make these functions safer. These functions require // casting things to void** which hides useful compiler warnings. Also needing // to pass in the correct elem_size is error prone. #define APFL_RESIZABLE_TRAIT(T, N) \ T* N; \ size_t len; \ size_t cap; #define APFL_RESIZABLE_ARGS(S, N) (void **)(&(S).N), &(S).len, &(S).cap void apfl_resizable_init(void **mem, size_t *len, size_t *cap); bool apfl_resizable_resize( struct apfl_allocator, size_t elem_size, void **mem, size_t *len, size_t *cap, size_t newlen ); bool apfl_resizable_ensure_cap( struct apfl_allocator, size_t elem_size, void **mem, size_t *cap, size_t want_cap ); bool apfl_resizable_ensure_cap_for_more_elements( struct apfl_allocator, size_t elem_size, void **mem, size_t len, size_t *cap, size_t more_elements ); bool apfl_resizable_check_cut_args(size_t len, size_t cut_start, size_t cut_len); bool apfl_resizable_cut_without_resize( size_t elem_size, void **mem, size_t *len, size_t cut_start, size_t cut_len ); bool apfl_resizable_splice( struct apfl_allocator, size_t elem_size, void **mem, size_t *len, size_t *cap, size_t start, size_t cut_len, const void *other_mem, size_t other_len ); bool apfl_resizable_append( struct apfl_allocator, size_t elem_size, void **mem, size_t *len, size_t *cap, const void *other_mem, size_t other_len ); #endif