bzero(3)

๐Ÿ’– bzero(3) โ€” the byte-array zero glow-up ๐Ÿ’–

okay bestie, gather round, because today we're talking about bzero, a little function from the Library Functions Manual section 3 that everyone's grandpa used and that POSIX straight-up ghosted. she's legacy, she's iconic, and she still works, so let's get into it. โœจ


๐ŸŒธ NAME ๐ŸŒธ

bzero โ€” byte-array zero. that's it, that's the whole job. she zeroes bytes. no cap. ๐ŸŽ€


๐Ÿ“š LIBRARY ๐Ÿ“š

Standard C library (that's libc, link it with -lc). she lives in the group chat with everyone else, she's not special, she's just dependable. ๐Ÿ’…


โœจ SYNOPSIS โœจ

#include <strings.h>  // see memory.h(3head)

void bzero(size_t n;
           void a[n], size_t n);

so you pull in <strings.h> (and hey, peep the note pointing you at memory.h(3head) โ€” iykyk) and then you call her like that. yes the signature looks a little unhinged, that's just how she's documented, don't come for me. ๐Ÿฆ‹


๐Ÿงš DESCRIPTION ๐Ÿงš

so what does she actually do?? she writes zeros ('\0') into the memory starting at the location that a points to. clean slate energy. starting fresh. main character reset arc. ๐ŸŒˆ

she is equivalent to:

memset(a, '\0', n)

literally the same vibe, different name. that's the whole thing, bestie, she's not hiding anything from you. ๐Ÿ’œ


๐Ÿซถ RETURN VALUE ๐Ÿซถ

None. she gives you nothing back. no value, no drama, just vibes. ๐Ÿ˜Œ


โญ ATTRIBUTES โญ

if you wanna know what all these fancy attribute words mean, go read attributes(7). here's the tea for bzero():

  • Interface: bzero()
  • Attribute: Thread safety
  • Value: MT-Safe

translation: she's safe to call from multiple threads at once. group project approved. ๐Ÿ‘‘


๐Ÿ“œ STANDARDS ๐Ÿ“œ

None. nobody claimed her. she's ungoverned. feral. free. ๐Ÿ’€


๐Ÿ•ฐ๏ธ HISTORY ๐Ÿ•ฐ๏ธ

  • 4.3BSD โ€” that's where she was born, vintage queen. ๐ŸŽ€
  • Marked as LEGACY in POSIX.1-2001.
  • Removed in POSIX.1-2008.

so yeah, POSIX said "we don't know her" and dropped her, but she's still kicking around in libc like the icon she is. not me getting emotional about a byte-zeroing function. ๐Ÿ˜ญ


โš ๏ธ CAVEATS โš ๏ธ

okay listen up because this part is IMPORTANT, no skimming. ๐Ÿ™ˆ

if your compiler figures out that the operation is unnecessary, it may totally or partially remove the call. like, just delete your zeroing. gone. into the void. not because she's broken but because the optimizer is doing a vibe check and deciding she's not needed.

to make sure the zeroing actually happens no matter what optimizations are in play, use explicit_bzero(3) instead.

fr fr, if you're doing security-adjacent stuff and you NEED those bytes zeroed, bzero might get optimized away on you. that's the whole reason explicit_bzero(3) exists. don't get caught lacking. ๐Ÿ’…

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€


and that's the page, bestie!! go forth and zero some bytes responsibly. ๐ŸŒธ

this lore comes to you straight from Linux man-pages 6.20, dated 2026-08-10. mwah, love you, bye!! ๐Ÿ’–๐ŸŽ€โœจ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: Linux-man-pages-copyleft
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms