From 19235b7127bcf5597fb0436deb45c2e6af5843c6 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 14 Sep 2021 17:19:12 -0400 Subject: 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. --- test/failing_allocator.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'test/failing_allocator.h') 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 -- cgit v1.2.1