BSON_STRDUP(3)

πŸ’… BSON_STRDUP(3) πŸ’…

okay so this is a libbson page bestie, welcome, pull up a chair πŸŽ€


✨ SYNOPSIS ✨

char *
bson_strdup (const char *str);

like, that's the whole vibe. one function. one string in, one string out. slay.


🌸 PARAMETERS 🌸

  • str β€” a string. that's it. that's the parameter. a string πŸ’–

πŸ¦‹ DESCRIPTION πŸ¦‹

so what does it do? it copies str into a brand new string. a whole new one. not a "here's a pointer to the same thing" situation, an actual fresh copy, no cap 🫢

and here's the cute little edge case: if str is NULL, then NULL is returned. it doesn't panic, it doesn't explode, it just hands you back NULL and minds its own business. iconic honestly.


πŸ‘‘ RETURNS πŸ‘‘

a newly allocated string πŸ”₯ and like β€” newly allocated is the key phrase here, so please, for the love of everything, free it with bson_free(). don't just let it vibe in memory forever, that's not the move πŸ’€


🌈 AUTHOR 🌈

MongoDB, Inc β€” yeah, that MongoDB. the ones you've heard of. iykyk πŸ’œ


2009-present, MongoDB, Inc. β€” the whole run, still going, periodt.


ngl this one's short and sweet, but it's giving "tiny function, big responsibility" β€” you still gotta bson_free() it. don't forget 😭

mwah, that's the page πŸ’… this was libbson 2.5.6, dated Oct 09, 2026 β€” go forth and duplicate responsibly, bestie 🧚✨

πŸ“¦ where this page comes from