aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmdsserver/macros.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-11-22 12:10:37 +0100
committerMattias Andrée <maandree@operamail.com>2014-11-22 12:11:33 +0100
commitd367918916baf9290816aa8657cc78878b68c1ef (patch)
treedddf55ae25b4d3c00be3b49f86f4c3e32276f6ab /src/libmdsserver/macros.h
parentm work on smplification (diff)
downloadmds-d367918916baf9290816aa8657cc78878b68c1ef.tar.gz
mds-d367918916baf9290816aa8657cc78878b68c1ef.tar.bz2
mds-d367918916baf9290816aa8657cc78878b68c1ef.tar.xz
Starting on some rework
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/libmdsserver/macros.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libmdsserver/macros.h b/src/libmdsserver/macros.h
index 79d427f..e7cfad5 100644
--- a/src/libmdsserver/macros.h
+++ b/src/libmdsserver/macros.h
@@ -38,6 +38,19 @@
/**
+ * Wrapper around `asprintf` that makes sure that first
+ * argument gets set to `NULL` on error and that zero is
+ * returned on success rather than the number of printed
+ * characters
+ *
+ * @param VAR:char** The output parameter for the string
+ * @param ...:const char*, ... The format string and arguments
+ * @return :int Zero on success, -1 on error
+ */
+#define xasprintf(VAR, ...) \
+ (asprintf(&(VAR), __VA_ARGS__) < 0 ? (VAR = NULL, -1) : 0)
+
+/**
* Wrapper for `snprintf` that allows you to forget about the buffer size
*
* @param buffer:char[] The buffer, must be of the type `char[]` and not `char*`