diff options
author | Martin Willi <martin@strongswan.org> | 2009-12-08 16:11:37 +0100 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2009-12-17 13:53:24 +0100 |
commit | 74eed73a40916ad5160d50209968cf093161db5f (patch) | |
tree | 56fda9416808fb5245809e1e3a7415fc6c60018e /src/libstrongswan/utils.h | |
parent | 6ec949e022a4dd36f19676f0ba825c8b7ffcb2f6 (diff) | |
download | strongswan-74eed73a40916ad5160d50209968cf093161db5f.tar.bz2 strongswan-74eed73a40916ad5160d50209968cf093161db5f.tar.xz |
Added a INIT() macro to initialize class instances
Diffstat (limited to 'src/libstrongswan/utils.h')
-rw-r--r-- | src/libstrongswan/utils.h | 6 |
1 files changed, 6 insertions, 0 deletions
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 @@ -109,6 +109,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. */ #define malloc_thing(thing) ((thing*)malloc(sizeof(thing))) |