summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--textbuf.c12
-rw-r--r--textbuf.h2
2 files changed, 14 insertions, 0 deletions
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);
diff --git a/textbuf.h b/textbuf.h
index e5e0f03..23b75d7 100644
--- a/textbuf.h
+++ b/textbuf.h
@@ -17,6 +17,8 @@ struct textbuf {
struct textbuf textbuf_init();
void textbuf_append(struct textbuf *textbuf, const char *str, int len);
+void textbuf_delete(struct textbuf *textbuf);
+void textbuf_clear(struct textbuf *textbuf);
void textbuf_free(struct textbuf *textbuf);
#endif