summaryrefslogtreecommitdiff
path: root/src/compat/nullpo.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/compat/nullpo.hpp')
-rw-r--r--src/compat/nullpo.hpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/compat/nullpo.hpp b/src/compat/nullpo.hpp
index 75f8110..5be674a 100644
--- a/src/compat/nullpo.hpp
+++ b/src/compat/nullpo.hpp
@@ -1,5 +1,4 @@
-#ifndef TMWA_COMPAT_NULLPO_HPP
-#define TMWA_COMPAT_NULLPO_HPP
+#pragma once
// nullpo.hpp - Non-fatal pointer assertions.
//
// Copyright © ????-2004 Athena Dev Teams
@@ -26,23 +25,28 @@
//# define BUG_FREE
/// All functions print to standard error (was: standard output)
-/// nullpo_ret(cond) - return 0 if given pointer is NULL
+/// nullpo_retn(cond) - return nullptr if given pointer is nullptr
+/// nullpo_retz(cond) - return 0 if given pointer is nullptr
/// nullpo_retv(cond) - just return (function returns void)
/// nullpo_retr(rv, cond) - return given value instead
-# ifndef BUG_FREE
-# define nullpo_retr(ret, t) \
+#ifndef BUG_FREE
+# define nullpo_retr(ret, t) \
if (nullpo_chk(__FILE__, __LINE__, __PRETTY_FUNCTION__, t)) \
return ret;
-# else // BUG_FREE
-# define nullpo_retr(ret, t) /*t*/
-# endif // BUG_FREE
+#else // BUG_FREE
+# define nullpo_retr(ret, t) /*t*/
+#endif // BUG_FREE
-# define nullpo_ret(t) nullpo_retr(0, t)
-# define nullpo_retv(t) nullpo_retr(, t)
+#define nullpo_retn(t) nullpo_retr(nullptr, t)
+#define nullpo_retz(t) nullpo_retr(0, t)
+#define nullpo_retv(t) nullpo_retr(, t)
-# include "../sanity.hpp"
+#include "fwd.hpp"
+
+namespace tmwa
+{
/// Used by macros in this header
bool nullpo_chk(const char *file, int line, const char *func,
const void *target);
@@ -57,5 +61,4 @@ bool nullpo_chk(const char *file, int line, const char *func, T *target)
{
return nullpo_chk(file, line, func, static_cast<const void *>(target));
}
-
-#endif // TMWA_COMPAT_NULLPO_HPP
+} // namespace tmwa