diff options
Diffstat (limited to 'test/test_hash.c')
-rw-r--r-- | test/test_hash.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/test/test_hash.c b/test/test_hash.c index b1de72a..2ff286c 100644 --- a/test/test_hash.c +++ b/test/test_hash.c @@ -10,11 +10,11 @@ #include "failing_allocator.h" #include "test_data.h" -#include "zix/allocator.h" -#include "zix/attributes.h" -#include "zix/digest.h" -#include "zix/hash.h" -#include "zix/status.h" +#include <zix/allocator.h> +#include <zix/attributes.h> +#include <zix/digest.h> +#include <zix/hash.h> +#include <zix/status.h> #include <assert.h> #include <inttypes.h> @@ -135,7 +135,7 @@ stress_with(ZixAllocator* const allocator, static const size_t string_length = 15; char* const buffer = (char*)calloc(1, n_elems * (string_length + 1)); - char** const strings = state.strings = (char**)calloc(sizeof(char*), n_elems); + char** const strings = state.strings = (char**)calloc(n_elems, sizeof(char*)); state.buffer = buffer; state.strings = strings; ENSURE(&state, buffer && state.strings, "Failed to allocate strings\n"); @@ -193,8 +193,8 @@ stress_with(ZixAllocator* const allocator, if (not_indexed) { memcpy(not_indexed, not_indexed_string, strlen(not_indexed_string) + 1); const char* match = (const char*)zix_hash_find_record(hash, not_indexed); - ENSUREV(&state, !match, "Unexpectedly found `%s'\n", not_indexed); free(not_indexed); + ENSUREV(&state, !match, "Unexpectedly found `%s'\n", not_indexed_string); } // Remove strings @@ -357,9 +357,9 @@ test_failed_alloc(void) assert(!stress(&allocator.base, 16)); // Test that each allocation failing is handled gracefully - const size_t n_new_allocs = allocator.n_allocations; + const size_t n_new_allocs = zix_failing_allocator_reset(&allocator, 0); for (size_t i = 0U; i < n_new_allocs; ++i) { - allocator.n_remaining = i; + zix_failing_allocator_reset(&allocator, i); assert(stress(&allocator.base, 16)); } } |