Files
mop3/ce/gapbuffer.h
kamkow1 49059f4bfa
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m31s
CE improve editor performace by reducing amount of copying
2026-03-06 22:14:42 +01:00

37 lines
982 B
C

#ifndef _GAPBUFFER_H
#define _GAPBUFFER_H
#include <arena.h>
#include <stddef.h>
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);
#endif // _GAPBUFFER_H