aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2020-10-08 08:41:46 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2020-10-08 11:24:31 +0200
commit3e9016f23f38a3243213badaa954725518fb9509 (patch)
tree05fb550c5e8fe8ab6602fbc6359b4d0ca625a8a5 /include
parentc862d84d0b6827106a53bc571c81eb523b05c50f (diff)
Add convenience macros for dynstr_prepend
Diffstat (limited to 'include')
-rw-r--r--include/dynstr.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/include/dynstr.h b/include/dynstr.h
index 38c05c5..72ebb4a 100644
--- a/include/dynstr.h
+++ b/include/dynstr.h
@@ -62,6 +62,39 @@
do {if (dynstr_append(__VA_ARGS__) != DYNSTR_OK) return 1;} while (0)
/**
+ * Convenience macro that calls dynstr_prepend and returns NULL if failed.
+ */
+#define dynstr_prepend_or_ret_null(...) \
+ do {if (dynstr_prepend(__VA_ARGS__) != DYNSTR_OK) return NULL;} while (0)
+
+/**
+ * Convenience macro that calls dynstr_prepend and returns false if failed.
+ */
+#define dynstr_prepend_or_ret_false(...) \
+ do {if (dynstr_prepend(__VA_ARGS__) != DYNSTR_OK) return false;} while (0)
+
+/**
+ * Convenience macro that calls dynstr_prepend and returns its error code if failed.
+ */
+#define dynstr_prepend_or_ret(...) \
+ { \
+ const enum dynstr_err err = dynstr_prepend(__VA_ARGS__); \
+ if (err != DYNSTR_OK) return err; \
+ }
+
+/**
+ * Convenience macro that calls dynstr_prepend and returns zero if failed.
+ */
+#define dynstr_prepend_or_ret_zero(...) \
+ do {if (dynstr_prepend(__VA_ARGS__) != DYNSTR_OK) return 0;} while (0)
+
+/**
+ * Convenience macro that calls dynstr_prepend and returns one if failed.
+ */
+#define dynstr_prepend_or_ret_nonzero(...) \
+ do {if (dynstr_prepend(__VA_ARGS__) != DYNSTR_OK) return 1;} while (0)
+
+/**
* Dynamic string type used for this library.
* @note If needed, members can be safely read but should not be modified
* outside this library.