BSON_SIZED_NEW(3)

✨ BSON_SIZED_NEW(3) ✨

okay bestie, so this is a page out of libbson and honestly it's short and sweet, we love a low-effort icon πŸ’…


🌸 SYNOPSIS 🌸

bson_t *
bson_sized_new (size_t size);

like, that's it. that's the whole vibe. πŸŽ€


πŸ¦‹ PARAMETERS πŸ¦‹

  • size β€” the size you want pre-allocated for the underlying buffer. yes, that's the whole parameter. she's simple, she's direct, we stan πŸ’–

🧚 DESCRIPTION 🧚

so the way that bson_sized_new() works is: it creates a new bson_t on the heap, and that bson_t comes with a preallocated buffer already set up for you ✨ no cap.

and like, when is this useful? when you actually have a good idea of how big your resulting document is gonna be πŸ‘€ then you tell it up front and it's giving prepared, it's giving organized, it's giving main character energy πŸ‘‘

tl;dr: you know the size, so you say the size, and the buffer is already waiting for you 🫢

πŸ”₯ RETURNS πŸ”₯

a freshly allocated bson_t πŸŽ‰ β€” and bestie, listen to me, you must free it with bson_destroy(). don't just leave her hanging, that's so not slay 😭 memory leaks are NOT the vibe.


🌈 AUTHOR 🌈

MongoDB, Inc β€” the icons themselves πŸ‘‘


2009-present, MongoDB, Inc. β€” periodt, protected πŸ’œ


okay that's the whole page, you're basically an expert now πŸ¦‹ this little number is from version 2.5.6, dated Oct 09, 2026 β€” mwah, go forth and allocate responsibly πŸ’…πŸŽ€

πŸ“¦ where this page comes from