Commit 768a00c1 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune Committed by Pål Hermunn Johansen

Introduce a ZERO_OBJ macro similar to bzero

It uses `explicit_bzero` when available and falls back to `memset`
otherwise.

Conflicts:
	configure.ac
parent 04b4e380
......@@ -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])
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment