From a57f05cfeb272039c476d89fa9a15d93dd0b7308 Mon Sep 17 00:00:00 2001 From: Timerix Date: Tue, 2 Dec 2025 14:46:19 +0500 Subject: [PATCH] zeroStruct --- include/tlibc/collections/LList.h | 2 +- include/tlibc/errors.h | 2 +- include/tlibc/std.h | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/tlibc/collections/LList.h b/include/tlibc/collections/LList.h index c5fafe4..2d0393b 100644 --- a/include/tlibc/collections/LList.h +++ b/include/tlibc/collections/LList.h @@ -21,7 +21,7 @@ static inline LLNode(T)* LLNode_##T##_createZero(){ \ LLNode(T)* n = (LLNode(T)*)malloc(sizeof(LLNode(T))); \ n->prev = NULL; \ n->next = NULL; \ - memset(&n->value, 0, sizeof(T)); \ + zeroStruct(&n->value); \ return n; \ } \ \ diff --git a/include/tlibc/errors.h b/include/tlibc/errors.h index 4585fe7..b57e70f 100755 --- a/include/tlibc/errors.h +++ b/include/tlibc/errors.h @@ -153,4 +153,4 @@ typedef struct Result_ { }\ } while(0) -#define try_assert(EXPR) if(!(EXPR)) { Return RESULT_ERROR(("try_assert(" #EXPR ")"), false); } +#define try_assert(EXPR) if(!(EXPR)) { Return RESULT_ERROR(("assertion must be true: " #EXPR), false); } diff --git a/include/tlibc/std.h b/include/tlibc/std.h index 5e64753..a2fd288 100755 --- a/include/tlibc/std.h +++ b/include/tlibc/std.h @@ -76,7 +76,7 @@ typedef void (*Destructor_t)(void* self); a48,a49,a50,a51,a52,a53,a54,a55, a56,a57,a58,a59,a60,a61,a62,a63, \ a64,...) a64 // Macro for counting variadic arguments (max 64) -// (see usage in kprint.h) +// (see usage in cptr.h) #define count_args(ARGS...) __count_args(ARGS, \ 64,63,62,61,60,59,58,57, 56,55,54,53,52,51,50,49, \ 48,47,46,45,44,43,42,41, 40,39,38,37,36,35,34,33, \ @@ -85,6 +85,8 @@ typedef void (*Destructor_t)(void* self); #define printfe(FORMAT, ...) fprintf(stderr, FORMAT ,##__VA_ARGS__) +#define zeroStruct(STRUCT_PTR) memset((STRUCT_PTR), 0, sizeof(*STRUCT_PTR)); + /// @warning pointer can be null #define NULLABLE(NAME) NAME