From 74eed73a40916ad5160d50209968cf093161db5f Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Tue, 8 Dec 2009 16:11:37 +0100 Subject: [PATCH] Added a INIT() macro to initialize class instances --- src/libstrongswan/utils.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libstrongswan/utils.h b/src/libstrongswan/utils.h index 3f8ffc6d4..ebc67db00 100644 --- a/src/libstrongswan/utils.h +++ b/src/libstrongswan/utils.h @@ -108,6 +108,12 @@ */ #define POS printf("%s, line %d\n", __FILE__, __LINE__) +/** + * Object allocation/initialization macro, using designated initializer. + */ +#define INIT(this, ...) { (this) = malloc(sizeof(*this)); \ + *(this) = (typeof(*this)){ __VA_ARGS__ }; } + /** * Macro to allocate a sized type. */