From 4ca3b74621c3608de42a91730a71892d9d7c27b5 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 1 Aug 2019 20:36:51 +0200 Subject: Remove nullable... it's bad to have magic. Static analysis can do it instead --- include/nullable.h | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) (limited to 'include/nullable.h') diff --git a/include/nullable.h b/include/nullable.h index 6c4d3a7..f84100b 100644 --- a/include/nullable.h +++ b/include/nullable.h @@ -3,27 +3,7 @@ struct __nullable_type_dummy{ int _; }; -int assert_not_null(void *val); - -#ifdef DEBUG -#define DefineNullablePtrType(type) \ - typedef struct type##_nullable type##_nullable; \ - struct type##_nullable { \ - type *value; \ - } -#define NullablePtr(type) type##_nullable -#define nullable_unwrap(nullable_type) \ - (assert_not_null((nullable_type).value) ? ((nullable_type).value) : NULL) -#define nullable_assign(nullable_type, new_value) ((nullable_type).value = (new_value)) -#define is_not_null(nullable_type) ((nullable_type).value != NULL) -#define nullable_raw(nullable_type) ((nullable_type).value) -#else -#define DefineNullablePtrType(type) -#define NullablePtr(type) type* -#define nullable_unwrap(value) value -#define nullable_assign(nullable_type, new_value) ((nullable_type) = (new_value)) -#define is_not_null(nullable_type) ((nullable_type) != NULL) -#define nullable_raw(nullable_type) (nullable_type) -#endif +/* Used by static analysis tool to find null-pointer dereference errors */ +#define nullable #endif -- cgit v1.2.3