BSON_APPEND_BINARY_UNINIT(3)
π 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β abson_t. that's your document, your canvas, your whole vibe β¨keyβ the key name. name your field something cute.key_lengthβ the length ofkeyin bytes, or-1to just letstrlen()handle it.-1is the "i trust you, bestie" option.subtypeβ abson_subtype_tthat 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 π
β COPYRIGHT β
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
- 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