explicit_bzero(3)

explicit_bzero3

Write zeroes to memory

Part of bzero(3).

Usage

#include <strings.h>

void

bzero(void *b, size_t len);

void

explicit_bzero(void *b, size_t len);

Library

Standard C Library (libc, -lc)

Overview

The bzero() function writes len zero bytes to the object b. If len is zero, bzero() does nothing.

The explicit_bzero() variant behaves the same, but will not be removed by a compiler's dead store optimization pass, making it useful for clearing sensitive memory such as a password.

Releases

25 releases since FreeBSD 11.0-RELEASE; the text changed 13 times.

  1. 11.0
  2. 11.1
  3. 11.2
  4. 11.3
  5. 11.4
  6. 12.0
  7. 12.1
  8. 12.2
  9. 12.3
  10. 12.4
  11. 13.0–13.2
  12. 13.3–14.5
  13. 15.0–15.1
  14. 16.0

History

A bzero() function appeared in 4.3BSD. Its prototype existed previously in ⟨string.h⟩ before it was moved to ⟨strings.h⟩ for IEEE Std 1003.1-2001 (“POSIX.1”) compliance.

The explicit_bzero() function first appeared in OpenBSD 5.5 and FreeBSD 11.0.

IEEE Std 1003.1-2008 (“POSIX.1”) removes the specification of bzero() and it is marked as LEGACY in IEEE Std 1003.1-2004 (“POSIX.1”). For portability with other systems new programs should use memset(3).

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.