diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2023-11-21 09:56:26 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2023-11-21 09:56:26 +0100 |
commit | 987942a206ef0f2342bf81d5de6432c6af42b7e7 (patch) | |
tree | 6befd1ab8680f2936d94ac84c94cf4f68f16c14e /src/tc-list.c | |
parent | 163bc6d7fc268bdb1c7cc03699f69d0c5cc0b4cd (diff) |
New upstream version 4.17upstream/4.17
Diffstat (limited to 'src/tc-list.c')
-rw-r--r-- | src/tc-list.c | 22 |
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; +} |