aboutsummaryrefslogtreecommitdiff
path: root/strbuf.c
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-01-21 11:42:12 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-01-21 11:42:12 +0100
commit86f7e40446106f8365df4f52af4ec2ee5dcb37aa (patch)
treeaa97d03d69e0e4ed51a3de7525d4370afac608c1 /strbuf.c
parentRename all instances of string to strbuf. (diff)
downloadcalp-86f7e40446106f8365df4f52af4ec2ee5dcb37aa.tar.gz
calp-86f7e40446106f8365df4f52af4ec2ee5dcb37aa.tar.xz
Remove all explicit malloc's.
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/strbuf.c b/strbuf.c
index 932b31e0..7f61313b 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -7,19 +7,19 @@
#define ERR(s) fprintf(stderr, "\x1B[0;31mERR\x1b[m (strbuf %3i): %s\n", __LINE__, s)
#endif
-int strbuf_init_0(strbuf* str) {
- str->mem = NULL;
- str->alloc = 0;
- str->len = 0;
- str->ptr = 0;
+int CONSTRUCTOR_DECL(strbuf) {
+ this->mem = NULL;
+ this->alloc = 0;
+ this->len = 0;
+ this->ptr = 0;
return 0;
}
-int strbuf_init_1(strbuf* str, size_t len) {
- str->mem = malloc(len);
- str->alloc = len;
- str->ptr = 0;
- str->len = 0;
+int CONSTRUCTOR_DECL(strbuf, size_t len) {
+ this->mem = calloc(sizeof(*this->mem), len);
+ this->alloc = len;
+ this->ptr = 0;
+ this->len = 0;
return 0;
}