diff options
Diffstat (limited to 'src/test.c')
| -rw-r--r-- | src/test.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test.c b/src/test.c new file mode 100644 index 0000000..40e1828 --- /dev/null +++ b/src/test.c @@ -0,0 +1,32 @@ +#include "strvec.h" +#include "allocator.h" + +#include <err.h> +#include <string.h> +#include <stdio.h> + +#define LIBSTRVEC_ERR(rc) errx(1, "libstrvec: %s", strerror(-rc)) + +int +main(int argc, const char **argv) +{ + struct strvec *strvec; + const char **arg; + + strvec = strvec_alloc(0, &stdlib_strict_heap_allocator, NULL); + + if (!argc) return 1; + for (arg = &argv[1]; *arg; arg++) { + strvec_push(strvec, *arg); + } + + strvec_push(strvec, "--"); + strvec_push(strvec, "end"); + strvec_push(strvec, NULL); + + for (arg = strvec_stra(strvec); *arg; arg++) { + printf("%s\n", *arg); + } + + strvec_free(strvec); +} |
