aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmdsserver
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-07-28 05:39:10 +0200
committerMattias Andrée <maandree@operamail.com>2014-07-28 05:39:10 +0200
commit941d700796d2dbb65ace8c775b5f3be4f4677650 (patch)
tree42f9377e139a4e34d346232f970947ac39ed290a /src/libmdsserver
parentmisc (diff)
downloadmds-941d700796d2dbb65ace8c775b5f3be4f4677650.tar.gz
mds-941d700796d2dbb65ace8c775b5f3be4f4677650.tar.bz2
mds-941d700796d2dbb65ace8c775b5f3be4f4677650.tar.xz
reduce code complexity
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/libmdsserver')
-rw-r--r--src/libmdsserver/macros.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libmdsserver/macros.h b/src/libmdsserver/macros.h
index 59537ff..cbef69c 100644
--- a/src/libmdsserver/macros.h
+++ b/src/libmdsserver/macros.h
@@ -323,6 +323,20 @@
/**
+ * Double to the size of an allocation on the heap
+ *
+ * @param old Variable in which to store the old value temporarily
+ * @param var The variable to which to assign the reallocation
+ * @param elements The number of elements to allocate
+ * @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 growalloc(old, var, elements, type) \
+ (old = var, xrealloc(var, (elements) <<= 1, type) ? (var = old, (elements) >>= 1, perror(*argv), 1) : 0)
+
+
+
+/**
* Go to the label `pfail` if a condition is met
*
* @param CONDITION The condition