From 85dd8e5fecc9c404edf65f21d24e6bf9fee9c822 Mon Sep 17 00:00:00 2001 From: Sara Date: Tue, 10 Sep 2024 09:47:14 +0200 Subject: [PATCH] feat: added new() and new_as() macros --- typeclass_helpers.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/typeclass_helpers.h b/typeclass_helpers.h index 1fca1a3..7c96b97 100644 --- a/typeclass_helpers.h +++ b/typeclass_helpers.h @@ -7,4 +7,7 @@ __Return (*const __Name##_)(__VA_ARGS__) = __Name; (void)__Name##_ #define decl_typeclass_impl(__Typeclass, __Type)\ extern __Typeclass __Type##_as_##__Typeclass(__Type*); +#define new(T) malloc(sizeof(T)) +#define new_as(T, TC) T##_as_##TC(new(T)) + #endif // !CUTES_TYPECLASS_HELPERS_H