diff options
author | David Robillard <d@drobilla.net> | 2021-06-29 15:45:50 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-01-13 23:04:20 -0500 |
commit | dc77dc04689254730de428e75a1da6f7a893c9e6 (patch) | |
tree | e2c2863a0e6c99be35d5470eb667164184c27889 /src/try.h | |
parent | 963909d052a617e7f3e2ff7a2dd6483f5629e698 (diff) | |
download | serd-dc77dc04689254730de428e75a1da6f7a893c9e6.tar.gz serd-dc77dc04689254730de428e75a1da6f7a893c9e6.tar.bz2 serd-dc77dc04689254730de428e75a1da6f7a893c9e6.zip |
Factor out TRY macro
Diffstat (limited to 'src/try.h')
-rw-r--r-- | src/try.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/try.h b/src/try.h new file mode 100644 index 00000000..82893887 --- /dev/null +++ b/src/try.h @@ -0,0 +1,27 @@ +/* + Copyright 2011-2021 David Robillard <d@drobilla.net> + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#ifndef SERD_TRY_H +#define SERD_TRY_H + +#define TRY(st, exp) \ + do { \ + if (((st) = (exp))) { \ + return (st); \ + } \ + } while (0) + +#endif // SERD_TRY_H |