summary refs log tree commit diff
path: root/edit.h
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2022-02-20 15:26:23 -0500
committerJune McEnroe <june@causal.agency>2022-02-20 15:42:24 -0500
commite39bba1a8a2fda74bcfd06f728b7e1fddadef161 (patch)
tree2add7aeaba4d0c69116c2f672d05e407fbffcdb3 /edit.h
parentClear edit buffer before running command (diff)
downloadcatgirl-e39bba1a8a2fda74bcfd06f728b7e1fddadef161.tar.gz
catgirl-e39bba1a8a2fda74bcfd06f728b7e1fddadef161.zip
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.
Diffstat (limited to '')
-rw-r--r--edit.h8
1 files changed, 2 insertions, 6 deletions
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);