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/failing_allocator.h | |
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/failing_allocator.h')
-rw-r--r-- | test/failing_allocator.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/test/failing_allocator.h b/test/failing_allocator.h index 89bee88..982874d 100644 --- a/test/failing_allocator.h +++ b/test/failing_allocator.h @@ -10,11 +10,12 @@ /// An allocator that fails after some number of successes for testing typedef struct { - size_t n_allocations; ///< The number of allocations that have been attempted - size_t n_remaining; ///< The number of remaining successful allocations -} ZixFailingAllocatorState; + ZixAllocator base; ///< Base allocator instance + size_t n_allocations; ///< Number of attempted allocations + size_t n_remaining; ///< Number of remaining successful allocations +} ZixFailingAllocator; -ZixAllocator -zix_failing_allocator(ZixFailingAllocatorState* state); +ZixFailingAllocator +zix_failing_allocator(void); #endif // ZIX_FAILING_ALLOCATOR_H |