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