BSON_DESTROY_WITH_STEAL(3)
π bson_destroy_with_steal π
okay so bestie, welcome to the libbson corner of the manual β this one's a libbson page, section 3, and it's literally about yeeting a bson_t while keeping its insides. iconic behavior honestly π
β¨ SYNOPSIS β¨
uint8_t *
bson_destroy_with_steal (bson_t *bson, bool steal, uint32_t *length);
that's the whole signature, no cap π«Ά
πΈ PARAMETERS πΈ
bsonβ abson_t. the main character of this whole situation πstealβ aboolthat says whether the underlying buffer should be stolen. yes, stolen. we're doing a heist πlengthβ a location where the resulting buffer length gets stashed π
π¦ DESCRIPTION π¦
so bson_destroy_with_steal() shall destroy a bson_t structure β but instead of freeing the underlying buffer, it hands it back to you. like, the bson dies, the buffer lives, it's giving resurrection arc β¨
if steal is false, then honestly this is just equivalent to calling bson_destroy(). no buffer, no heist, nothing stolen. shrug π
β οΈ okay this part is important, fr fr: it is a programming error to call this function on abson_tthat is not a top-levelbson_tβ like the ones you get frombson_append_document_begin(),bson_append_array_begin(), andbson_writer_begin(). do not do that. i'm begging π«Ά
π RETURNS π
bson_destroy_with_steal() shall return a buffer holding the contents of the bson_t if steal is non-zero. and when you're done with it, free it with bson_free() β that's the cleanup era, we love a responsible queen π§
length will be set to the length of the bson document if it's non-NULL. if it's NULL? then it just doesn't get set, periodt π
π« SEE ALSO π«
bson_steal()β a higher-level function that efficiently transfers the contents of onebson_tto another. lowkey the upgraded version of this vibe β¨
π AUTHOR π
MongoDB, Inc β the ones who wrote all this, we stan π
β COPYRIGHT β
2009-present, MongoDB, Inc.
and that's the page!! π this was libbson 2.5.6, dated Oct 09, 2026, page BSON_DESTROY_WITH_STEAL(3) β go forth and steal those buffers responsibly, bestie ππ₯
π¦ 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