summaryrefslogtreecommitdiff
path: root/src/utils/checkutils.h
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-05-04 22:46:17 +0300
committerAndrei Karas <akaras@inbox.ru>2016-05-04 22:46:17 +0300
commitb0227c5cbf0dada9fc46ade54686da369629de5e (patch)
tree133cc32e9fa8582d9e819c2c6ffb924c7f1e3a02 /src/utils/checkutils.h
parentbf9c58df65f48416dd7ae02cae96228ab6bec6d4 (diff)
downloadmanaverse-b0227c5cbf0dada9fc46ade54686da369629de5e.tar.gz
manaverse-b0227c5cbf0dada9fc46ade54686da369629de5e.tar.bz2
manaverse-b0227c5cbf0dada9fc46ade54686da369629de5e.tar.xz
manaverse-b0227c5cbf0dada9fc46ade54686da369629de5e.zip
Add macroses returnNullptr and returnNullptrV
Diffstat (limited to 'src/utils/checkutils.h')
-rw-r--r--src/utils/checkutils.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/utils/checkutils.h b/src/utils/checkutils.h
index 7b76da8f1..52545e5cb 100644
--- a/src/utils/checkutils.h
+++ b/src/utils/checkutils.h
@@ -73,6 +73,22 @@
return ret; \
}
+#define returnNullptrV(val) \
+ if ((val) == nullptr) \
+ { \
+ reportStack(__FILE__, __LINE__, __func__, \
+ "Detected null value", #val); \
+ return; \
+ }
+
+#define returnNullptr(ret, val) \
+ if ((val) == nullptr) \
+ { \
+ reportStack(__FILE__, __LINE__, __func__, \
+ "Detected null value", #val); \
+ return ret; \
+ }
+
void reportStack(const char *const file,
const unsigned int line,
const char *const func,
@@ -102,5 +118,13 @@ void reportStack(const char *const file,
if (val) \
return ret;
+#define returnNullptrV(val) \
+ if ((val) == nullptr) \
+ return; \
+
+#define returnNullptr(ret, val) \
+ if ((val) == nullptr) \
+ return ret; \
+
#endif // ENABLE_ASSERTS
#endif // UTILS_CHECKUTILS_H