summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2012-03-26 08:29:13 +0200
committerYorhel <git@yorhel.nl>2012-03-26 08:29:13 +0200
commit26fb2015d3824caa7e8cfa8eff0db68995f3afa6 (patch)
treee7c36c60ba59b4b28c91a4ade2b9c166fa978d30
parentc9d2990fffbc4ea0fc143d82b4db68dcf5b93bdb (diff)
Added const keyword to some string arguments
-rw-r--r--tanja.c12
-rw-r--r--tanja.h12
2 files changed, 12 insertions, 12 deletions
diff --git a/tanja.c b/tanja.c
index c616ff8..40cd4b6 100644
--- a/tanja.c
+++ b/tanja.c
@@ -308,7 +308,7 @@ char *tn_el_str(tn_el el, char *buf) {
}
-tn_el tn_array_new(char *lst, ...) {
+tn_el tn_array_new(const char *lst, ...) {
tn_el a;
a.count = a.size = strlen(lst);
a.type = TN_VT_AR;
@@ -336,7 +336,7 @@ static inline void tn_array_grow(tn_el *a, int new) {
}
-void tn_array_append(tn_el *a, char *lst, ...) {
+void tn_array_append(tn_el *a, const char *lst, ...) {
assert(a && a->type == TN_VT_AR);
int n = strlen(lst);
@@ -410,7 +410,7 @@ static inline void tn_map_set_one(tn_el *m, char *key, tn_el val) {
}
-tn_el tn_map_new(int s, char *lst, ...) {
+tn_el tn_map_new(int s, const char *lst, ...) {
tn_el a;
a.type = TN_VT_MAP;
a.v.m = NULL;
@@ -433,7 +433,7 @@ tn_el tn_map_new(int s, char *lst, ...) {
}
-void tn_map_set(tn_el *m, char *lst, ...) {
+void tn_map_set(tn_el *m, const char *lst, ...) {
assert(m && m->type == TN_VT_MAP);
int len = strlen(lst);
tn_map_grow(m, len);
@@ -476,7 +476,7 @@ void tn_tuple_unref(tn_tuple *tup) {
}
-tn_tuple *tn_tuple_new(char *lst, ...) {
+tn_tuple *tn_tuple_new(const char *lst, ...) {
tn_tuple *t = malloc(offsetof(tn_tuple, e) + strlen(lst)*sizeof(tn_el));
t->n = strlen(lst);
t->ref = 1;
@@ -529,7 +529,7 @@ int tn_tuple_match(tn_tuple *p, tn_tuple *t) {
lbuf_append((*buf), _s, _len);\
} while(0)
-static inline void json_fmt_string(char *str, lbuf *buf) {
+static inline void json_fmt_string(const char *str, lbuf *buf) {
ac('\"');
while(*str) {
switch(*str) {
diff --git a/tanja.h b/tanja.h
index a2a208a..bcd9f97 100644
--- a/tanja.h
+++ b/tanja.h
@@ -102,14 +102,14 @@ int64_t tn_el_int(tn_el);
int tn_el_numval(tn_el, double *);
double tn_el_num(tn_el);
char *tn_el_str(tn_el, char *);
-tn_el tn_array_new(char *, ...);
-void tn_array_append(tn_el *, char *, ...);
-tn_el tn_map_new(int, char *, ...);
-void tn_map_set(tn_el *, char *, ...);
-tn_el tn_map_get(tn_el, const char *);
+tn_el tn_array_new(const char *, ...);
+void tn_array_append(tn_el *, const char *, ...);
+tn_el tn_map_new(int, const char *, ...);
+void tn_map_set(tn_el *, const char *, ...);
+tn_el tn_map_get(tn_el, const const char *);
void tn_tuple_ref(tn_tuple *);
void tn_tuple_unref(tn_tuple *);
-tn_tuple *tn_tuple_new(char *, ...);
+tn_tuple *tn_tuple_new(const char *, ...);
int tn_tuple_match(tn_tuple *, tn_tuple *);
char *tn_json_fmt(tn_tuple *);