]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: i_zero*() - Update comment, especially about arrays
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 13 May 2019 13:03:27 +0000 (16:03 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 13 May 2019 13:03:27 +0000 (16:03 +0300)
src/lib/macros.h

index ea1a612205cd591791e5c982b678eaaafdc229e0..bade9396db618462cc5d4b550d8c9ffd8987b132 100644 (file)
 #  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) \