|
|
|
@ -206,7 +206,7 @@ increment(char* word, size_t word_len)
|
|
|
|
|
size_t i; |
|
|
|
|
count c = { .word = w, .count = 0 }; |
|
|
|
|
|
|
|
|
|
if (y_err(val == NULL)) y_exit(y_STATUS_MISC_ERR); |
|
|
|
|
if (y_err(val == NULL)) y_exit(y_status_exits[y_STATUS_MISC_ERR]); |
|
|
|
|
|
|
|
|
|
*val += 1; |
|
|
|
|
|
|
|
|
@ -227,7 +227,7 @@ increment(char* word, size_t word_len)
|
|
|
|
|
if (w.word == NULL) |
|
|
|
|
{ |
|
|
|
|
y_eprintf("Could not allocate\n"); |
|
|
|
|
y_exit(y_STATUS_MALLOC_FAIL); |
|
|
|
|
y_exit(y_status_exits[y_STATUS_MALLOC_FAIL]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// NOLINTNEXTLINE
|
|
|
|
@ -239,7 +239,7 @@ increment(char* word, size_t word_len)
|
|
|
|
|
if (s != y_STATUS_SUCCESS) |
|
|
|
|
{ |
|
|
|
|
y_eprintf("Could not insert\n"); |
|
|
|
|
y_exit(y_STATUS_MISC_ERR); |
|
|
|
|
y_exit(y_status_exits[y_STATUS_MISC_ERR]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
count c = { .word = w, .count = wcount }; |
|
|
|
@ -249,7 +249,7 @@ increment(char* word, size_t word_len)
|
|
|
|
|
if (s != y_STATUS_SUCCESS) |
|
|
|
|
{ |
|
|
|
|
y_eprintf("Could not push\n"); |
|
|
|
|
y_exit(y_STATUS_MISC_ERR); |
|
|
|
|
y_exit(y_status_exits[y_STATUS_MISC_ERR]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
assert(y_vec_sorted(vec, cmp_safe)); |
|
|
|
@ -262,7 +262,7 @@ increment(char* word, size_t word_len)
|
|
|
|
|
y_map_exists_kv(table, &w, &temp, &val); |
|
|
|
|
#endif // YC_DEBUG
|
|
|
|
|
|
|
|
|
|
if (y_err(temp == NULL)) y_exit(y_STATUS_MISC_ERR); |
|
|
|
|
if (y_err(temp == NULL)) y_exit(y_status_exits[y_STATUS_MISC_ERR]); |
|
|
|
|
|
|
|
|
|
y_printf("%s: %zu (%zu)\n", temp->word, *val, y_map_size(table)); |
|
|
|
|
} |
|
|
|
@ -271,7 +271,7 @@ int
|
|
|
|
|
main() |
|
|
|
|
{ |
|
|
|
|
y_Status s = y_main(false, false); |
|
|
|
|
if (y_err(s != y_STATUS_SUCCESS)) y_exit(s); |
|
|
|
|
if (y_err(s != y_STATUS_SUCCESS)) y_exit(y_status_exits[s]); |
|
|
|
|
|
|
|
|
|
// Allocate hash table buckets.
|
|
|
|
|
table = y_map_create(0.96f, sizeof(word_data), sizeof(size_t), hash, eq, |
|
|
|
@ -281,7 +281,7 @@ main()
|
|
|
|
|
if (table == NULL || vec == NULL) |
|
|
|
|
{ |
|
|
|
|
y_eprintf("Out of memory\n"); |
|
|
|
|
y_exit(y_STATUS_MALLOC_FAIL); |
|
|
|
|
y_exit(y_status_exits[y_STATUS_MALLOC_FAIL]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
char* buf = strdup(kjvbible_array); |
|
|
|
@ -342,14 +342,14 @@ main()
|
|
|
|
|
if (num_unique != y_vec_len(vec)) |
|
|
|
|
{ |
|
|
|
|
y_eprintf("Vector and map are different sizes\n"); |
|
|
|
|
y_exit(y_STATUS_MISC_ERR); |
|
|
|
|
y_exit(y_status_exits[y_STATUS_MISC_ERR]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (num_unique != 32187) |
|
|
|
|
{ |
|
|
|
|
y_eprintf("Vector and map are the wrong size;\n"); |
|
|
|
|
y_eprintf("Expected 32187, got %zu\n", num_unique); |
|
|
|
|
y_exit(y_STATUS_MISC_ERR); |
|
|
|
|
y_exit(y_status_exits[y_STATUS_MISC_ERR]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
count* ordered_map = calloc(num_unique, sizeof(count)); |
|
|
|
@ -358,7 +358,7 @@ main()
|
|
|
|
|
if (ordered_map == NULL || ordered_vec == NULL) |
|
|
|
|
{ |
|
|
|
|
y_eprintf("Out of memory\n"); |
|
|
|
|
y_exit(y_STATUS_MALLOC_FAIL); |
|
|
|
|
y_exit(y_status_exits[y_STATUS_MALLOC_FAIL]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
i = 0; |
|
|
|
@ -387,7 +387,7 @@ main()
|
|
|
|
|
if (!y_map_exists(table, &ordered_vec[i].word)) |
|
|
|
|
{ |
|
|
|
|
y_eprintf("Map does not have an element that the vector does\n"); |
|
|
|
|
y_exit(y_STATUS_MISC_ERR); |
|
|
|
|
y_exit(y_status_exits[y_STATUS_MISC_ERR]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -422,7 +422,7 @@ main()
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (bad) y_exit(y_STATUS_MISC_ERR); |
|
|
|
|
if (bad) y_exit(y_status_exits[y_STATUS_MISC_ERR]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (i = 0; i < num_unique; i++) |
|
|
|
@ -435,5 +435,5 @@ main()
|
|
|
|
|
y_vec_free(vec); |
|
|
|
|
y_map_free(table); |
|
|
|
|
|
|
|
|
|
y_exit(y_STATUS_SUCCESS); |
|
|
|
|
y_exit(y_status_exits[y_STATUS_SUCCESS]); |
|
|
|
|
} |
|
|
|
|