diff options
| author | Louis Burda <quent.burda@gmail.com> | 2023-05-13 21:12:17 +0200 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2023-05-13 21:12:17 +0200 |
| commit | 9fe89a48bb89dc6740787c9ed8c95b5339bba905 (patch) | |
| tree | bca73651945caef5e188328a538ca782470c43dd /src/test.c | |
| parent | 110b99563e127abe1439fffb0084400b47eea5b3 (diff) | |
| download | libstrvec-c-9fe89a48bb89dc6740787c9ed8c95b5339bba905.tar.gz libstrvec-c-9fe89a48bb89dc6740787c9ed8c95b5339bba905.zip | |
Add initial version
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); +} |
