summaryrefslogtreecommitdiff
path: root/src/common.h
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2020-01-12 10:31:07 +0000
committerEdward Thomson <ethomson@edwardthomson.com>2020-05-11 20:13:54 +0100
commita95096ba5f72db71422ffd9ea6630160387b97c0 (patch)
treee081be31e5393d7db534b30f18af8b6fe5065344 /src/common.h
parentabe2efe1ff84d423ef5f104b1e95e9ef66442c0f (diff)
downloadlibgit2-a95096ba5f72db71422ffd9ea6630160387b97c0.tar.gz
assert: optionally fall-back to assert(3)
Fall back to the system assert(3) in debug builds, which may aide in debugging. "Safe" assertions can be enabled in debug builds by setting GIT_ASSERT_HARD=0. Similarly, hard assertions can be enabled in release builds by setting GIT_ASSERT_HARD to nonzero.
Diffstat (limited to 'src/common.h')
-rw-r--r--src/common.h28
1 files changed, 1 insertions, 27 deletions
diff --git a/src/common.h b/src/common.h
index 959dd5772..2b1a4a456 100644
--- a/src/common.h
+++ b/src/common.h
@@ -80,6 +80,7 @@
#include "errors.h"
#include "thread-utils.h"
#include "integer.h"
+#include "assert_safe.h"
/*
* Include the declarations for deprecated functions; this ensures
@@ -95,33 +96,6 @@
#define NETIO_BUFSIZE DEFAULT_BUFSIZE
/**
- * Assert that a consumer-provided argument is valid, setting an
- * actionable error message and returning -1 if it is not.
- *
- * Note that memory leaks can occur in a release-mode assertion
- * failure -- it is impractical to provide safe clean up routines in these very
- * extreme failures, but care should be taken to not leak very large objects.
- */
-#define GIT_ASSERT_ARG(expr) do { \
- if (!(expr)) { \
- git_error_set(GIT_ERROR_INVALID, \
- "invalid argument: '%s'", \
- #expr); \
- return -1; \
- } \
- } while(0)
-
-/** Internal consistency check to stop the function. */
-#define GIT_ASSERT(expr) do { \
- if (!(expr)) { \
- git_error_set(GIT_ERROR_INTERNAL, \
- "unrecoverable internal error: '%s'", \
- #expr); \
- return -1; \
- } \
- } while(0)
-
-/**
* Check a pointer allocation result, returning -1 if it failed.
*/
#define GIT_ERROR_CHECK_ALLOC(ptr) if (ptr == NULL) { return -1; }