aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-02-21 15:22:47 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-02-21 15:23:26 +0100
commitcdc5e2cec5de1eb29ea3a42148c0b1302e97877f (patch)
tree0dd8d9fbfd7fb168be5778db93ffc4b6a29f1cc5
parentMade to compile as C++. (diff)
downloadcalp-cdc5e2cec5de1eb29ea3a42148c0b1302e97877f.tar.gz
calp-cdc5e2cec5de1eb29ea3a42148c0b1302e97877f.tar.xz
Fix c++ compile warnings.
-rw-r--r--strbuf.c2
-rw-r--r--strbuf.h2
-rw-r--r--vcal.c15
-rw-r--r--vcal.h6
4 files changed, 16 insertions, 9 deletions
diff --git a/strbuf.c b/strbuf.c
index f17de211..54960a54 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -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;
diff --git a/strbuf.h b/strbuf.h
index c531734e..de4cc29b 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -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.
diff --git a/vcal.c b/vcal.c
index 7f674dac..2f736892 100644
--- a/vcal.c
+++ b/vcal.c
@@ -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) {
diff --git a/vcal.h b/vcal.h
index 1c96c4c6..95811a7b 100644
--- a/vcal.h
+++ b/vcal.h
@@ -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);