BSON_APPEND_BINARY_UNINIT(3)

πŸ“¦
version 2.5.6 Β· 3 versions
, in epel 10

πŸ’… BSON_APPEND_BINARY_UNINIT(3) ✨

okay bestie, so this one is a page from the libbson manual, and it's literally called BSON_APPEND_BINARY_UNINIT β€” say that five times fast, i dare you. it's giving "i know what i'm doing" main character energy, so let's get into it 🫢


🌸 SYNOPSIS 🌸

so first up, there's a macro, and macros are lowkey just shortcuts with extra steps:

#define BSON_APPEND_BINARY_UNINIT(b, key, subtype, val, len) \
   bson_append_binary_uninit (b, key, (int) strlen (key), subtype, val, len)

and then the actual function it wraps, which is the real icon here:

bool
bson_append_binary_uninit (bson_t *bson,
                           const char *key,
                           int key_length,
                           bson_subtype_t subtype,
                           uint8_t **binary,
                           uint32_t length);

yes bestie, two stars on uint8_t **binary β€” that's the whole point of this function, we'll get there πŸ’–


πŸŽ€ PARAMETERS πŸŽ€

  • bson β€” a bson_t. that's your document, your canvas, your whole vibe ✨
  • key β€” the key name. name your field something cute.
  • key_length β€” the length of key in bytes, or -1 to just let strlen() handle it. -1 is the "i trust you, bestie" option.
  • subtype β€” a bson_subtype_t that says which binary subtype this is. gotta label your stuff 🏷️
  • binary β€” location for a pointer that will receive a writable pointer to the uninitialized binary data block. yes β€” uninitialized. it's a blank canvas, no cap.
  • length β€” the length of buffer in bytes.

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so bson_append_binary_uninit() is the alternative to bson_append_binary() β€” she's the cool cousin 😎 β€” and what she does is let applications assemble the contents of the binary field within the bson_t, without an additional temporary buffer. no middleman, no extra allocation, we love efficiency πŸ’…

⚠️ but listen β€” on success, the caller MUST write to every byte of the binary data block if the resulting bson_t is to be used. every. single. byte. bestie. don't leave any of it uninitialized and then act surprised 😭

and one more thing, the buffer that binary points to is only valid until the iterator's bson_t is otherwise modified or freed. so like… use it now or lose it forever. it's giving limited-edition drop 🌈


πŸ”₯ RETURNS πŸ”₯

returns true if the uninitialized binary item was appended β€” slay πŸŽ‰

the function will fail if appending binary grows bson larger than INT32_MAX. like, she has limits, okay? we all do πŸ’€


πŸ’œ AUTHOR πŸ’œ

MongoDB, Inc β€” icons only πŸ‘‘

2009-present, MongoDB, Inc. β€” protect the legacy 🫑


and that's the whole page, bestie β€” no notes, ate and left no crumbs πŸ“

signing off with all the deets: this was BSON_APPEND_BINARY_UNINIT(3) from libbson, version 2.5.6, dated Oct 09, 2026 πŸ’– see you in the next manpage, love u!! ✨

πŸ“¦ where this page comes from