diff options
-rw-r--r-- | strbuf.c | 2 | ||||
-rw-r--r-- | strbuf.h | 2 | ||||
-rw-r--r-- | vcal.c | 15 | ||||
-rw-r--r-- | vcal.h | 6 |
4 files changed, 16 insertions, 9 deletions
@@ -87,7 +87,7 @@ int strbuf_cmp(strbuf* a, strbuf* b) { return strncmp(a->mem, b->mem, a->len); } -int strbuf_c(strbuf* a, char* b) { +int strbuf_c(strbuf* a, const char* b) { if (a == NULL || a->alloc == 0) { ERR("a not allocated"); return -1; @@ -40,7 +40,7 @@ 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); +int strbuf_c(strbuf* a, const char* b); /* * Copy contents from src to dest. @@ -41,11 +41,11 @@ INIT_F(vcomponent) { return 0; } -INIT_F(vcomponent, char* type) { +INIT_F(vcomponent, const char* type) { return INIT(vcomponent, self, type, NULL); } -INIT_F(vcomponent, char* type, char* filename) { +INIT_F(vcomponent, const char* type, const char* filename) { INIT(TRIE(content_line), &self->clines); INIT(VECT(vcomponent), &self->components); @@ -83,8 +83,15 @@ content_line* RESOLVE(content_line) return dest; } -content_line* get_property (vcomponent* ev, char* key) { - return GET(TRIE(content_line))(&ev->clines, key); +content_line* get_property (vcomponent* ev, const char* key) { + size_t len = strlen(key) + 1; + char* cpy = (char*) (calloc(sizeof(*cpy), len)); + strncpy (cpy, key, len); + + content_line* ret = GET(TRIE(content_line))(&ev->clines, cpy); + + free (cpy); + return ret; } FREE_F(vcomponent) { @@ -96,11 +96,11 @@ struct s_vcomponent { #define FCHILD(v) GET(VECT(vcomponent))(&(v)->components, 0) INIT_F(vcomponent); -INIT_F(vcomponent, char* type); -INIT_F(vcomponent, char* type, char* filename); +INIT_F(vcomponent, const char* type); +INIT_F(vcomponent, const char* type, const char* filename); FREE_F(vcomponent); -content_line* get_property (vcomponent* ev, char* key); +content_line* get_property (vcomponent* ev, const char* key); int add_content_line (vcomponent* ev, content_line* c); |