diff options
author | Hugo Hörnquist <hugo@hornquist.se> | 2019-02-10 18:55:06 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-02-15 20:03:40 +0100 |
commit | 78409a2251e345249316f3fcccb31d7b8ba97ccb (patch) | |
tree | 5ccac8f847b4f259456cb1055cae5afe61c454b7 | |
parent | Move trie->dot from trie to graphs. Add value printing. (diff) | |
download | calp-78409a2251e345249316f3fcccb31d7b8ba97ccb.tar.gz calp-78409a2251e345249316f3fcccb31d7b8ba97ccb.tar.xz |
Merge strbuf copy functions.
-rw-r--r-- | parse.c | 10 | ||||
-rw-r--r-- | strbuf.c | 8 | ||||
-rw-r--r-- | strbuf.h | 10 | ||||
-rw-r--r-- | vcal.c | 4 |
4 files changed, 11 insertions, 21 deletions
@@ -68,7 +68,7 @@ int parse_file(char* filename, FILE* f, vcomponent* root) { exit (2); } - strbuf_copy(cline.vals.cur->value, &ctx.str); + DEEP_COPY(strbuf)(cline.vals.cur->value, &ctx.str); strbuf_cap(cline.vals.cur->value); strbuf_soft_reset(&ctx.str); @@ -85,7 +85,7 @@ int parse_file(char* filename, FILE* f, vcomponent* root) { * Border between param {key, value} */ } else if (p_ctx == p_param_name && c == '=') { - strbuf_copy(&kv.key, &ctx.str); + DEEP_COPY(strbuf)(&kv.key, &ctx.str); strbuf_cap(&kv.key); strbuf_soft_reset(&ctx.str); @@ -103,7 +103,7 @@ int parse_file(char* filename, FILE* f, vcomponent* root) { if (p_ctx == p_key) dest = &cline.key; else if (p_ctx == p_param_value) dest = &kv.val; - strbuf_copy(dest, &ctx.str); + DEEP_COPY(strbuf)(dest, &ctx.str); strbuf_cap(dest); strbuf_soft_reset(&ctx.str); @@ -132,7 +132,7 @@ int parse_file(char* filename, FILE* f, vcomponent* root) { * the end here. */ - strbuf_copy(cline.vals.cur->value, &ctx.str); + DEEP_COPY(strbuf)(cline.vals.cur->value, &ctx.str); strbuf_cap(cline.vals.cur->value); handle_kv(&cline, &ctx); @@ -163,7 +163,7 @@ int handle_kv ( */ NEW(strbuf, s); - strbuf_copy(s, cline->vals.cur->value); + DEEP_COPY(strbuf)(s, cline->vals.cur->value); PUSH(LLIST(strbuf))(&ctx->key_stack, s); NEW(vcomponent, e, @@ -62,8 +62,7 @@ int strbuf_cap(strbuf* s) { return strbuf_append(s, 0); } - -int strbuf_copy(strbuf* dest, strbuf* src) { +int DEEP_COPY(strbuf)(strbuf* dest, strbuf* src) { int retval = 0; if (dest->alloc < src->len) { @@ -110,11 +109,6 @@ char* strbuf_cur(strbuf* s) { return &s->mem[s->ptr]; } -/* TODO merge this and strbuf_copy */ -int DEEP_COPY(strbuf)(strbuf* dest, strbuf* src) { - return strbuf_copy(dest, src); -} - char* strbuf_end(strbuf* s) { return &s->mem[s->len]; } @@ -39,17 +39,13 @@ int strbuf_realloc(strbuf* str, size_t len); */ FREE_F(strbuf); +int strbuf_cmp(strbuf* a, strbuf* b); +int strbuf_c(strbuf* a, char* b); + /* * Copy contents from src to dest. * Assumes that dest is already initialized. - * - * also see: strbuf_alloc_copy */ -int strbuf_copy(strbuf* dest, strbuf* src); - -int strbuf_cmp(strbuf* a, strbuf* b); -int strbuf_c(strbuf* a, char* b); - int DEEP_COPY(strbuf)(strbuf*, strbuf*); /* @@ -178,7 +178,7 @@ FMT_F(key_val) { } int DEEP_COPY(key_val) (key_val* dest, key_val* src) { - strbuf_copy(&dest->key, &src->key); - strbuf_copy(&dest->val, &src->val); + DEEP_COPY(strbuf)(&dest->key, &src->key); + DEEP_COPY(strbuf)(&dest->val, &src->val); return 0; } |