BSON_STRNLEN(3)

πŸ’… BSON_STRNLEN(3) πŸ’…

okay so this is bson_strnlen, and it lives in libbson (that's the manual name bestie, we're in libbson land πŸ¦‹). it's a tiny little function but it's lowkey doing the most for portability, and honestly? we stan a supportive icon.


✨ SYNOPSIS ✨

size_t
bson_strnlen (const char *s, size_t maxlen);

literally the whole signature, no notes πŸ’–


πŸŽ€ PARAMETERS πŸŽ€

  • s β€” a string. that's it, that's the whole vibe. just a string 🫢
  • maxlen β€” the maximum size of string to check. like a little fence so we don't run off the edge 🌸

🌈 DESCRIPTION 🌈

so bson_strnlen() is a portable version of strnlen(). that's the entire description and honestly it ate πŸ’… if your platform is being weird about strnlen(), this is your girl. main character energy, works everywhere, no cap.


⭐ RETURNS ⭐

it gives you back the length of s in bytes β€” OR maxlen if no \0 was found. so basically: it counts until it hits the null terminator, but if there's no \0 in sight it just throws its hands up and reports maxlen 😭 no drama, no overrun, just boundaries. we love a queen who respects limits πŸ’€βœ¨


πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc β€” the icons behind it all πŸ’œ


2009-present, MongoDB, Inc. β€” yeah, they've been at this a minute, fr fr 🧚


and that's the whole page bestie!! written by the libbson girlies in version 2.5.6, dated Oct 09, 2026 β€” go forth and measure your strings safely, mwah πŸ’–πŸŽ€πŸ”₯

πŸ“¦ where this page comes from