BSON_ZERO_FREE(3)

πŸŽ€ BSON_ZERO_FREE(3) πŸŽ€

okay so bestie, we're in the libbson house today and this one's a little function with main character energy: bson_zero_free. yes the name is lowercase in code, yes that's just how it is, no we're not changing it πŸ’…


✨ SYNOPSIS ✨

void
bson_zero_free (void *mem, size_t size);

like, that's the whole signature. adorable. look at it go 🫢


🌸 PARAMETERS 🌸

  • mem β€” A memory region. literally just a pointer to some bytes, that's the vibe ✨
  • size β€” The size of mem. gotta tell it how many bytes, iykyk πŸ’–

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea bestie: this function behaves exactly like bson_free() β€” except that it zeroes the memory first. same free, but with a little pre-cleanup glow-up 🧼✨

why would u care? because this can be useful if you're storing passwords or other similarly important data πŸ” like if the bytes just sit there in memory after being freed, that's giving security nightmare, and we don't do that πŸ’€

⚠️ real talk though: note that if it truly is important, you probably want a page protected with mlock() as well, to prevent it swapping to disk. zeroing the memory is slay, but if the OS yeets the page to swap the zeroing is lowkey not enough. periodt πŸ”₯

πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc β€” yup, that's the author. iconic of them honestly 🫢


2009-present, MongoDB, Inc. β€” that's the whole copyright line, no cap πŸ’œ


and that's the page, bestie! πŸ’– this one's from libbson, version 2.5.6, dated Oct 09, 2026 β€” go forth and zero that memory before you free it, you absolute legend πŸ‘‘πŸ¦‹βœ¨

πŸ“¦ where this page comes from