#ifndef _GAPBUFFER_H #define _GAPBUFFER_H #include #include struct gapbuffer { char* buffer; size_t size; size_t gap_start; size_t gap_end; }; typedef void* (*gb_malloc_func_t) (void*, size_t); typedef void* (*gb_realloc_func_t) (void*, void*, size_t, size_t); typedef void (*gb_free_func_t) (void*, void*); void gapbuffer_init (gb_malloc_func_t mallocfn, void* ctx, struct gapbuffer* gb, size_t capacity); void gapbuffer_fini (gb_free_func_t freefn, void* ctx, struct gapbuffer* gb); void gapbuffer_move (struct gapbuffer* gb, size_t pos); void gapbuffer_insert (gb_realloc_func_t reallocfn, void* ctx, struct gapbuffer* gb, char c); void gapbuffer_backspace (struct gapbuffer* gb); void gapbuffer_grow (gb_realloc_func_t reallocfn, void* ctx, struct gapbuffer* gb); size_t gapbuffer_length (struct gapbuffer* gb); char* gapbuffer_string_at (gb_malloc_func_t mallocfn, void* ctx, struct gapbuffer* gb, size_t pos); char gapbuffer_at (struct gapbuffer* gb, size_t index); #endif // _GAPBUFFER_H