aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmdsserver/macros.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libmdsserver/macros.h')
-rw-r--r--src/libmdsserver/macros.h21
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