From 5cb53f39f2ecab5fd189686651b4fc8ccd834218 Mon Sep 17 00:00:00 2001 From: Sara Date: Wed, 22 Nov 2023 11:45:58 +0100 Subject: [PATCH] reworked default drop implementation --- core/src/drop.c | 6 ++++++ core/src/drop.h | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 core/src/drop.c diff --git a/core/src/drop.c b/core/src/drop.c new file mode 100644 index 0000000..7bd372a --- /dev/null +++ b/core/src/drop.c @@ -0,0 +1,6 @@ +#include "drop.h" +#include "stdlib.h" + +void default_drop(void* data) { + free(data); +} diff --git a/core/src/drop.h b/core/src/drop.h index e5aaef4..c5a9936 100644 --- a/core/src/drop.h +++ b/core/src/drop.h @@ -19,8 +19,13 @@ static inline Drop T##_as_Drop(T* x) {\ return (Drop){.tc = &tc, .data = x};\ } -#define impl_default_Drop_for(T)\ - static void default_drop_##T(T* v) { free(v); }\ - impl_Drop_for(T, default_drop_##T) +extern void default_drop(void*); +#define impl_default_Drop_for(T)\ +static inline Drop T##_as_Drop(T* x) {\ + static IDrop const tc = {\ + .drop = default_drop,\ + };\ + return (Drop){.tc = &tc, .data = x};\ +} #endif // !_fencer_drop_h