summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2012-03-25 04:56:15 +0200
committerYorhel <git@yorhel.nl>2012-03-25 04:58:46 +0200
commit854f714e4f08e04c2461503b634fbe3a8a0058c6 (patch)
treed3f190658434c7d88c7f9c0c0d779b585176105d
parent8b5dbf8a06182013e3151cac8dceda46c1c1aeea (diff)
Pass va_list around as a pointer rather than a value
Apparently, the only thing you're allowed to do with a va_list variable is calling va_end() after passing it to a function. Passing the va_list as a pointer does what I want. (This resulted in problems on my 32bit Arch installation, it worked fine on 64bit)
-rw-r--r--tanja.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/tanja.c b/tanja.c
index e41cd77..b7497dc 100644
--- a/tanja.c
+++ b/tanja.c
@@ -172,15 +172,15 @@ void tn_el_free(tn_el el) {
}
-static inline tn_el el_newv(char t, va_list va) {
+static inline tn_el el_newv(char t, va_list *va) {
if(t == TN_VT_AR || t == TN_VT_MAP)
return va_arg(va, tn_el);
tn_el a;
a.type = t;
switch(t) {
- case TN_VT_INT: a.v.i = va_arg(va, int64_t); break;
- case TN_VT_NUM: a.v.n = va_arg(va, double); break;
- case TN_VT_STR: a.v.s = va_arg(va, char *); break;
+ case TN_VT_INT: a.v.i = va_arg(*va, int64_t); break;
+ case TN_VT_NUM: a.v.n = va_arg(*va, double); break;
+ case TN_VT_STR: a.v.s = va_arg(*va, char *); break;
default: assert(t == TN_VT_WC);
}
return a;
@@ -190,7 +190,7 @@ static inline tn_el el_newv(char t, va_list va) {
tn_el tn_el_new(char t, ...) {
va_list va;
va_start(va, t);
- tn_el e = el_newv(t, va);
+ tn_el e = el_newv(t, &va);
va_end(va);
return e;
}
@@ -318,7 +318,7 @@ tn_el tn_array_new(char *lst, ...) {
a.v.a = malloc(a.size*sizeof(tn_el));
int i;
for(i=0; i<a.count; i++)
- a.v.a[i] = el_newv(lst[i], va);
+ a.v.a[i] = el_newv(lst[i], &va);
} else
a.v.a = NULL;
va_end(va);
@@ -346,7 +346,7 @@ void tn_array_append(tn_el *a, char *lst, ...) {
va_start(va, lst);
int i;
for(i=0; i<n; i++)
- a->v.a[a->count++] = el_newv(lst[i], va);
+ a->v.a[a->count++] = el_newv(lst[i], &va);
va_end(va);
}
@@ -426,7 +426,7 @@ tn_el tn_map_new(int s, char *lst, ...) {
int i;
for(i=0; i<len; i++) {
char *k = va_arg(va, char *);
- tn_map_set_one(&a, k, el_newv(lst[i], va));
+ tn_map_set_one(&a, k, el_newv(lst[i], &va));
}
va_end(va);
return a;
@@ -442,7 +442,7 @@ void tn_map_set(tn_el *m, char *lst, ...) {
int i;
for(i=0; i<len; i++) {
char *k = va_arg(va, char *);
- tn_map_set_one(m, k, el_newv(lst[i], va));
+ tn_map_set_one(m, k, el_newv(lst[i], &va));
}
va_end(va);
}
@@ -484,7 +484,7 @@ tn_tuple *tn_tuple_new(char *lst, ...) {
va_start(va, lst);
int i;
for(i=0; i<t->n; i++)
- t->e[i] = el_newv(lst[i], va);
+ t->e[i] = el_newv(lst[i], &va);
va_end(va);
return t;
}