From c3da108c2d41853beb49a90a1f43a2a9a158c385 Mon Sep 17 00:00:00 2001 From: cflip Date: Tue, 31 Jan 2023 10:44:54 -0700 Subject: Add functions to delete and clear a textbuf --- textbuf.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'textbuf.c') diff --git a/textbuf.c b/textbuf.c index e68ddbd..6bbb74c 100644 --- a/textbuf.c +++ b/textbuf.c @@ -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); -- cgit v1.2.3