We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f4e6896 commit 0f353a9Copy full SHA for 0f353a9
code/logic/fossil/sys/cnullptr.h
@@ -16,6 +16,7 @@
16
17
#include <stdint.h>
18
#include <stddef.h>
19
+#include <assert.h>
20
21
#ifdef __cplusplus
22
extern "C" {
@@ -85,6 +86,17 @@ extern "C" {
85
86
*/
87
#define cmaybe(ptr, default_val) ((ptr) ? (ptr) : (default_val))
88
89
+/**
90
+ * @brief Unwraps a pointer, asserting that it is not null.
91
+ *
92
+ * If the pointer is null, the program will terminate with an assertion failure.
93
+ * Otherwise, it returns the pointer itself for safe dereferencing.
94
95
+ * @param ptr The pointer to unwrap.
96
+ * @return The unwrapped pointer if it is not null.
97
+ */
98
+#define cunwrap(ptr) (assert((ptr) != cnull), (ptr))
99
+
100
/**
101
* @brief Marks a variable as unused to suppress compiler warnings.
102
*
0 commit comments