summaryrefslogtreecommitdiff
path: root/src/tc-list.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tc-list.c')
-rw-r--r--src/tc-list.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/tc-list.c b/src/tc-list.c
index 2fd6380..e8a30b6 100644
--- a/src/tc-list.c
+++ b/src/tc-list.c
@@ -22,7 +22,7 @@ union list_encap {
static HXCLIST_HEAD(strings_ct);
-static void l_init(unsigned int max, bool unshift)
+static int l_init(unsigned int max, bool unshift)
{
static const char *const msg[] = {"Pushing", "Unshifting"};
struct text_object *obj;
@@ -34,7 +34,7 @@ static void l_init(unsigned int max, bool unshift)
#else
obj = malloc(sizeof(*obj));
if (obj == NULL)
- abort();
+ return EXIT_FAILURE;
#endif
HXlist_init(&obj->list);
obj->id[0] = HX_irand('a', 'z'+1);
@@ -48,6 +48,7 @@ static void l_init(unsigned int max, bool unshift)
else
HXclist_push(&strings_ct, &obj->list);
}
+ return EXIT_SUCCESS;
}
static void l_traverse(void)
@@ -137,16 +138,17 @@ static void l_shift(void)
#pragma GCC diagnostic pop
}
-int main(int argc, const char **argv)
+static int runner(int argc, const char **argv)
{
unsigned int max = 10;
if (HX_init() <= 0)
- abort();
+ return EXIT_FAILURE;
if (argc >= 2)
max = strtoul(argv[1], NULL, 0);
-
- l_init(max, HX_rand() & 1);
+ int ret = l_init(max, HX_rand() & 1);
+ if (ret != EXIT_SUCCESS)
+ return ret;
l_traverse();
l_dump(HX_rand() & 1);
l_empty();
@@ -154,3 +156,11 @@ int main(int argc, const char **argv)
HX_exit();
return EXIT_SUCCESS;
}
+
+int main(int argc, const char **argv)
+{
+ int ret = runner(argc, argv);
+ if (ret != EXIT_FAILURE)
+ fprintf(stderr, "FAILED\n");
+ return ret;
+}