BSON_VALUE_COPY(3)

πŸ’– BSON_VALUE_COPY(3) πŸ’–

okay bestie, welcome to the libbson page for bson_value_copy() β€” the little function that’s all about copying the boxed value content without leaking memory. it’s giving β€œsimple but you MUST read the fine print” energy, fr fr. πŸ’…


✨ SYNOPSIS ✨

void
bson_value_copy (const bson_value_t *src, bson_value_t *dst);

πŸŽ€ PARAMETERS πŸŽ€

  • src β€” a bson_value_t to copy from. the source, the original, the main character πŸ‘‘
  • dst β€” a bson_value_t to copy into. the destination, the copy era πŸ¦‹

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this function will copy the boxed content in src into dst. yes bestie, it’s a copy-copy situation. πŸ’–

dst must be freed with bson_value_destroy() when no longer in use. that’s the cleanup step, don’t skip it. 🧚

and this is the important part: dst MUST be an uninitialized bson_value_t to avoid leaking memory. like, MUST MUST. not β€œeh, maybe.” no cap. 😭

NOTE: if src represents a BSON UTF-8 string, bson_value_copy() attempts to NULL terminate the copied string in dst. if src.value.v_utf8.len is SIZE_MAX, the copied string is (necessarily) not NULL terminated. so yeah, that’s the vibe check on that one πŸ’€

πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc β€” iconic, honestly. 🫢


2009-present, MongoDB, Inc. β€” periodt, protect the copyright bestie πŸ’œ


xoxo, your libbson bestie 🌸 β€” this is version 2.5.6, dated Oct 09, 2026. bye bestie, go copy safely and don’t leak! πŸ’…βœ¨

πŸ“¦ where this page comes from