From e39bba1a8a2fda74bcfd06f728b7e1fddadef161 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Sun, 20 Feb 2022 15:26:23 -0500 Subject: Move mbs out of struct Edit, use a global buffer This saves 4K in the edit buffers, not to mention all the heap allocations for the separate mbs buffers! There might be a way to be more clever about capacities, but I don't think it's worth it. --- edit.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'edit.h') diff --git a/edit.h b/edit.h index 49adb7f..9cf814b 100644 --- a/edit.h +++ b/edit.h @@ -42,10 +42,6 @@ struct Edit { wchar_t *buf; size_t len; } cut; - struct { - char *buf; - size_t pos; - } mbs; }; enum EditFn { @@ -76,8 +72,8 @@ int editVi(struct Edit *e, wchar_t ch); // Insert a character at the cursor. int editInsert(struct Edit *e, wchar_t ch); -// Convert the buffer to a multi-byte string stored in e->mbs. -char *editString(struct Edit *e); +// Convert the buffer to a multi-byte string. +char *editString(const struct Edit *e, char **buf, size_t *cap, size_t *pos); // Free all buffers. void editFree(struct Edit *e); -- cgit 1.4.1-2-gfad0