reworked default drop implementation

This commit is contained in:
Sara 2023-11-22 11:45:58 +01:00
parent 9f3bfcb879
commit 5cb53f39f2
2 changed files with 14 additions and 3 deletions

6
core/src/drop.c Normal file
View file

@ -0,0 +1,6 @@
#include "drop.h"
#include "stdlib.h"
void default_drop(void* data) {
free(data);
}

View file

@ -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