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 ofmem. 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 π«Ά
π COPYRIGHT π
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
- epel 10: libbson-devel 2.5.6-1.el10_3 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms