diff options
author | David Robillard <d@drobilla.net> | 2021-09-14 17:19:12 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-09-14 17:19:12 -0400 |
commit | 19235b7127bcf5597fb0436deb45c2e6af5843c6 (patch) | |
tree | bb0207a4799f67933cd793e0501d09a10822c5ec /test/ring_test.c | |
parent | 9572ea596d07147dbfb6db7772623e740ce28652 (diff) | |
download | zix-19235b7127bcf5597fb0436deb45c2e6af5843c6.tar.gz zix-19235b7127bcf5597fb0436deb45c2e6af5843c6.tar.bz2 zix-19235b7127bcf5597fb0436deb45c2e6af5843c6.zip |
Make ZixAllocator a single flat struct
I can never decide between these two patterns for polymorphic objects in C, but
this one seems more appropriate here since it's more conducive to inheritance.
Diffstat (limited to 'test/ring_test.c')
-rw-r--r-- | test/ring_test.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/test/ring_test.c b/test/ring_test.c index b4fa5f1..ba2a4d1 100644 --- a/test/ring_test.c +++ b/test/ring_test.c @@ -161,18 +161,17 @@ test_ring(const unsigned size) static void test_failed_alloc(void) { - ZixFailingAllocatorState state = {0u, SIZE_MAX}; - ZixAllocator allocator = zix_failing_allocator(&state); + ZixFailingAllocator allocator = zix_failing_allocator(); // Successfully allocate a ring to count the number of allocations - ring = zix_ring_new(&allocator, 512); + ring = zix_ring_new(&allocator.base, 512); assert(ring); // Test that each allocation failing is handled gracefully - const size_t n_new_allocs = state.n_allocations; + const size_t n_new_allocs = allocator.n_allocations; for (size_t i = 0u; i < n_new_allocs; ++i) { - state.n_remaining = i; - assert(!zix_ring_new(&allocator, 512)); + allocator.n_remaining = i; + assert(!zix_ring_new(&allocator.base, 512)); } zix_ring_free(ring); |