From 4c69a8a7b59e2607b5e198cd076739fbf45af0a5 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 28 Sep 2014 00:49:15 +0200 Subject: m + make sure the code ends with a new line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/libmdsserver/macros.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/libmdsserver') diff --git a/src/libmdsserver/macros.h b/src/libmdsserver/macros.h index 481d281..79d427f 100644 --- a/src/libmdsserver/macros.h +++ b/src/libmdsserver/macros.h @@ -330,6 +330,20 @@ ((var = realloc(var, (elements) * sizeof(type))) == NULL) +/** + * `xremalloc` that stores the old variable + * + * @param old:type* The variable to which to store with the old variable that needs + * to be `free`:ed on failure, and set to `NULL` on success. + * @param var:type* The variable to which to assign the reallocation + * @param elements:size_t 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 xxrealloc(old, var, elements, type) \ + (old = var, (xrealloc(var, elements, type) ? 1 : (old = NULL, 0))) + + /** * Double to the size of an allocation on the heap * -- cgit v1.2.3-70-g09d2