aboutsummaryrefslogtreecommitdiff
path: root/strbuf.h
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-01-21 11:37:43 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-01-21 11:37:43 +0100
commitada4556833ce249a0d4c3c2a5a91e0a6a01b837f (patch)
treec2e94d36b5ead42f5cf3090acd6566ede0090a80 /strbuf.h
parentBunch of renames + macros. (diff)
downloadcalp-ada4556833ce249a0d4c3c2a5a91e0a6a01b837f.tar.gz
calp-ada4556833ce249a0d4c3c2a5a91e0a6a01b837f.tar.xz
Rename all instances of string to strbuf.
Diffstat (limited to 'strbuf.h')
-rw-r--r--strbuf.h40
1 files changed, 19 insertions, 21 deletions
diff --git a/strbuf.h b/strbuf.h
index 1a49ca5d..af673693 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -2,41 +2,39 @@
#define STRBUF_H
#include <stdlib.h>
+#include "macro.h"
typedef struct {
char* mem;
size_t ptr;
size_t alloc;
size_t len;
-} string;
+} strbuf;
/*
- * TODO rename everything to be on the form
- * strbuf_.*
- *
* TODO Check memmory allocation for last +1 byte for null.
*/
/*
- * Init string to size of 0
+ * Init strbuf to size of 0
* Doesnt't call malloc.
*/
-int strbuf_init_0(string* str);
+int CONSTRUCTOR_DECL(strbuf);
/*
* Constructor
*/
-int strbuf_init_1(string* str, size_t len);
+int CONSTRUCTOR_DECL(strbuf, size_t len);
/*
* Like realloc, but for strbuf
*/
-int realloc_string(string* str, size_t len);
+int strbuf_realloc(strbuf* str, size_t len);
/*
* Free's contents of str, but keeps str.
*/
-int free_string(string* str);
+int strbuf_free(strbuf* str);
/*
* Copy contents from src to dest.
@@ -44,37 +42,37 @@ int free_string(string* str);
*
* also see: strbuf_alloc_copy
*/
-int copy_strbuf(string* dest, string* src);
-int strbuf_cmp(string* a, string* b);
-int strbuf_c(string* a, char* b);
+int strbuf_copy(strbuf* dest, strbuf* src);
+int strbuf_cmp(strbuf* a, strbuf* b);
+int strbuf_c(strbuf* a, char* b);
/*
- * Append char to end of string, determined by s->len.
+ * Append char to end of strbuf, determined by s->len.
*/
-int strbuf_append(string* s, char c);
+int strbuf_append(strbuf* s, char c);
/*
* Calls strbuf_append with NULL.
*/
-int strbuf_cap(string* s);
-int strbuf_reset(string* s);
-char* charat(string* s, int idx);
-char* strbuf_cur(string* s);
+int strbuf_cap(strbuf* s);
+int strbuf_reset(strbuf* s);
+char* charat(strbuf* s, int idx);
+char* strbuf_cur(strbuf* s);
/*
* Sets the length and seek ptr to 0, but doesn't touch the memmory.
*/
-int strbuf_soft_reset(string* s);
+int strbuf_soft_reset(strbuf* s);
/*
* Returns the character after the last, so where null hopefully is.
*/
-char* strbuf_end(string* s);
+char* strbuf_end(strbuf* s);
/*
* Copies contents from src to dest, also allocating dest in the
* process. dest should not be initialized before this call.
*/
-int strbuf_init_copy(string* dest, string* src);
+int strbuf_init_copy(strbuf* dest, strbuf* src);
#endif /* STRBUF_H */