From f62954aaff74651365d3fcb7411b5d95bda640a9 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Mon, 13 May 2019 16:03:27 +0300 Subject: [PATCH] lib: i_zero*() - Update comment, especially about arrays --- src/lib/macros.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/macros.h b/src/lib/macros.h index ea1a612205..bade9396db 100644 --- a/src/lib/macros.h +++ b/src/lib/macros.h @@ -234,7 +234,14 @@ # define STATIC_ARRAY #endif -/* Convenience wrappers for initializing a struct */ +/* Convenience wrappers for initializing a struct with zeros, although it can + be used for replacing other memset()s also. + + // NOTE: This is the correct way to zero the whole array + char arr[5]; i_zero(&arr); + // This will give compiler error (or zero only the first element): + char arr[5]; i_zero(arr); +*/ #define i_zero(p) \ memset(p, 0 + COMPILE_ERROR_IF_TRUE(sizeof(p) > sizeof(void *)), sizeof(*(p))) #define i_zero_safe(p) \ -- 2.47.3