aboutsummaryrefslogtreecommitdiff
path: root/buffer.h
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-12-18 13:50:19 +0100
committerMarc André Tanner <mat@brain-dump.org>2014-12-18 16:57:18 +0100
commitb8456fa2615480fa242c6992ca89481a8370fe5f (patch)
tree4836c8561242182ea5d13d735fe6432e9d5624c4 /buffer.h
parent46ffdc3dff7a8bf87f3b1004c3c12a7f6fcd8d6c (diff)
downloadvis-b8456fa2615480fa242c6992ca89481a8370fe5f.tar.gz
vis-b8456fa2615480fa242c6992ca89481a8370fe5f.tar.xz
Macro support
At some point this should be optimized further at the moment there is some 20 byte overhead for each entered key.
Diffstat (limited to 'buffer.h')
-rw-r--r--buffer.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/buffer.h b/buffer.h
new file mode 100644
index 0000000..190f579
--- /dev/null
+++ b/buffer.h
@@ -0,0 +1,20 @@
+#ifndef BUFFER_H
+#define BUFFER_H
+
+#include <stddef.h>
+#include <stdbool.h>
+#include "text.h"
+
+typedef struct {
+ char *data; /* NULL if empty */
+ size_t len; /* current length of data */
+ size_t size; /* maximal capacity of the buffer */
+} Buffer;
+
+void buffer_free(Buffer *buf);
+bool buffer_alloc(Buffer *buf, size_t size);
+void buffer_truncate(Buffer *buf);
+bool buffer_put(Buffer *buf, void *data, size_t len);
+bool buffer_append(Buffer *buf, void *data, size_t len);
+
+#endif