diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/dynstr.h | 33 |
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. |
