Skip to content

Commit

Permalink
check va_copy
Browse files Browse the repository at this point in the history
  • Loading branch information
Hakuyume committed Aug 16, 2022
1 parent c21a50e commit 1b5d96b
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions tests/items/src/varargs.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,27 @@ struct vastruct {

// pattern first seen in apache (util_script.c)
void valist_struct_member(const char *fmt, ...) {
struct vastruct thestruct;

va_start(thestruct.args, fmt);
vprintf(fmt, thestruct.args);
va_end(thestruct.args);
struct vastruct a, b;

va_start(a.args, fmt);
va_copy(b.args, a.args);
vprintf(fmt, a.args);
vprintf(fmt, b.args);
va_end(a.args);
va_end(b.args);
}

// pattern first seen in graphviz (sftable.c)
void valist_struct_pointer_member(const char *fmt, ...) {
struct vastruct thestruct;
struct vastruct *pointer = &thestruct;

va_start(pointer->args, fmt);
vprintf(fmt, pointer->args);
va_end(pointer->args);
struct vastruct a, b;
struct vastruct *p = &a, *q = &b;

va_start(p->args, fmt);
va_copy(q->args, p->args);
vprintf(fmt, p->args);
vprintf(fmt, q->args);
va_end(p->args);
va_end(q->args);
}

// mirrors pattern from json-c's sprintbuf
Expand Down

0 comments on commit 1b5d96b

Please sign in to comment.