New API for relocating the buffer

This commit is contained in:
Francesco Cozzuto
2023-04-01 19:29:43 +02:00
parent a1224382b7
commit 6d6613dddf
5 changed files with 173 additions and 264 deletions
+8 -9
View File
@@ -1,6 +1,3 @@
#warning "temp"
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
@@ -11,7 +8,7 @@ typedef struct {
bool crossed_gap;
size_t cur;
void *mem;
char maybe[256];
char maybe[512];
} GapBufferIter;
typedef struct {
@@ -19,10 +16,10 @@ typedef struct {
size_t len;
} GapBufferLine;
GapBuffer *GapBuffer_createUsingMemory(void *mem, size_t len);
GapBuffer *GapBuffer_create(size_t capacity);
GapBuffer *GapBuffer_createUsingMemory(void *mem, size_t len, void (*free)(void*));
GapBuffer *GapBuffer_cloneUsingMemory(void *mem, size_t len, void (*free)(void*), const GapBuffer *src);
void GapBuffer_destroy(GapBuffer *buff);
bool GapBuffer_insertString(GapBuffer **buff, const char *str, size_t len);
bool GapBuffer_insertString(GapBuffer *buff, const char *str, size_t len);
void GapBuffer_moveRelative(GapBuffer *buff, int off);
void GapBuffer_moveAbsolute(GapBuffer *buff, size_t num);
void GapBuffer_removeForwards(GapBuffer *buff, size_t num);
@@ -31,5 +28,7 @@ void GapBufferIter_init(GapBufferIter *iter, GapBuffer *buff);
void GapBufferIter_free(GapBufferIter *iter);
bool GapBufferIter_next(GapBufferIter *iter, GapBufferLine *line);
#warning "temporarily not static"
int getSymbolRune(const char *sym, size_t symlen, uint32_t *rune);
#ifndef GAPBUFFER_NOMALLOC
GapBuffer *GapBuffer_create(size_t capacity);
bool GapBuffer_insertStringMaybeRelocate(GapBuffer **buff, const char *str, size_t len);
#endif