[4.1] 768a00c Introduce a ZERO_OBJ macro similar to bzero
PÃ¥l Hermunn Johansen
hermunn at varnish-software.com
Thu Apr 6 12:50:06 CEST 2017
commit 768a00c185437b24021ccce8debf232c26b605c4
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Fri Feb 17 18:06:39 2017 +0100
Introduce a ZERO_OBJ macro similar to bzero
It uses `explicit_bzero` when available and falls back to `memset`
otherwise.
Conflicts:
configure.ac
diff --git a/configure.ac b/configure.ac
index a145726..5c61a61 100644
--- a/configure.ac
+++ b/configure.ac
@@ -251,6 +251,7 @@ AC_CHECK_FUNCS([strerror])
AC_FUNC_STRERROR_R
AC_CHECK_FUNCS([dladdr])
AC_CHECK_FUNCS([socket])
+AC_CHECK_FUNCS([explicit_bzero])
AC_CHECK_FUNCS([nanosleep])
AC_CHECK_FUNCS([setppriv])
AC_CHECK_FUNCS([fallocate])
diff --git a/include/miniobj.h b/include/miniobj.h
index 901143f..75093ce 100644
--- a/include/miniobj.h
+++ b/include/miniobj.h
@@ -5,6 +5,12 @@
*
*/
+#if HAVE_EXPLICIT_BZERO
+# define ZERO_OBJ(to, sz) explicit_bzero(to, sz)
+#else
+# define ZERO_OBJ(to, sz) (void)memset(to, 0, sz)
+#endif
+
#define INIT_OBJ(to, type_magic) \
do { \
(void)memset(to, 0, sizeof *to); \
@@ -20,7 +26,7 @@
#define FREE_OBJ(to) \
do { \
- (to)->magic = (0); \
+ ZERO_OBJ(&(to)->magic, sizeof (to)->magic); \
free(to); \
to = NULL; \
} while (0)
More information about the varnish-commit
mailing list