diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-05-18 05:22:13 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-05-18 05:22:13 +0200 |
commit | c49d626ed36f0af1f2ffe970c24b5177d9e9b197 (patch) | |
tree | 5b688d77766be1f6436fb071acec0214579ae72f /src/libmdsserver/macros.h | |
parent | reduce code complexity (diff) | |
download | mds-c49d626ed36f0af1f2ffe970c24b5177d9e9b197.tar.gz mds-c49d626ed36f0af1f2ffe970c24b5177d9e9b197.tar.bz2 mds-c49d626ed36f0af1f2ffe970c24b5177d9e9b197.tar.xz |
style + reduce code complexity
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/libmdsserver/macros.h | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/libmdsserver/macros.h b/src/libmdsserver/macros.h index d70afc9..1623950 100644 --- a/src/libmdsserver/macros.h +++ b/src/libmdsserver/macros.h @@ -276,7 +276,7 @@ * * @param var The variable to which to assign the allocation * @param elements The number of elements to allocate - * @parma type The data type of the elements for which to create an allocation + * @param type The data type of the elements for which to create an allocation * @return :int Evaluates to true if an only if the allocation failed */ #define xmalloc(var, elements, type) \ @@ -288,12 +288,29 @@ * * @param var The variable to which to assign the allocation * @param elements The number of elements to allocate - * @parma type The data type of the elements for which to create an allocation + * @param type The data type of the elements for which to create an allocation * @return :int Evaluates to true if an only if the allocation failed */ #define xcalloc(var, elements, type) \ ((var = calloc(elements, sizeof(type))) == NULL) +/** + * Go to the label `pfail` if a condition is met + * + * @param CONDITION The condition + */ +#define fail_if(CONDITION) if (CONDITION) goto pfail + + +/** + * Run a set of instructions and return 1 if a condition is met + * + * @param CONDITION The condition + * @param INSTRUCTIONS The instruction (semicolon-terminated) + */ +#define exit_if(CONDITION, INSTRUCTIONS) if (CONDITION) { INSTRUCTIONS return 1; } + + #endif |