diff options
author | cflip <cflip@cflip.net> | 2023-01-31 10:44:54 -0700 |
---|---|---|
committer | cflip <cflip@cflip.net> | 2023-01-31 10:44:54 -0700 |
commit | c3da108c2d41853beb49a90a1f43a2a9a158c385 (patch) | |
tree | f5e95175aad8db3d8c7a19d5a6c021d4076c9f68 /textbuf.c | |
parent | 24addd792a50ff47a904f819375bed32b32039a0 (diff) |
Add functions to delete and clear a textbuf
Diffstat (limited to 'textbuf.c')
-rw-r--r-- | textbuf.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -26,6 +26,18 @@ void textbuf_append(struct textbuf *textbuf, const char *str, int len) textbuf->length += len; } +void textbuf_delete(struct textbuf *textbuf) +{ + textbuf->buffer[textbuf->length] = '\0'; + textbuf->length--; +} + +void textbuf_clear(struct textbuf *textbuf) +{ + textbuf_free(textbuf); + *textbuf = textbuf_init(); +} + void textbuf_free(struct textbuf *textbuf) { free(textbuf->buffer); |