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,bzeromight get optimized away on you. that's the whole reasonexplicit_bzero(3)exists. don't get caught lacking. ๐
๐ SEE ALSO ๐
bstring(3)memory.h(3head)explicit_zero(3)memset(3)
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
- Copyright 2017, Michael Kerrisk <mtk.manpages@gmail.com>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms