SDL_strnlen(3)
π SDL_strnlen β the vibe check on your string length π
okay so bestie, welcome to SDL_strnlen, a lil function from the SDL3 FUNCTIONS fam. It does exactly what strnlen() does, except it doesn't need access to a C runtime, which is lowkey iconic of it.
β¨ NAME β¨
SDL_strnlen β works exactly like strnlen() but doesn't require access to a C runtime. no cap, that's the whole pitch π«Ά
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_stdinc.h>
size_t SDL_strnlen(const char *str, size_t maxlen);
π¦ DESCRIPTION π¦
So what it actually does: it counts up to a maximum of maxlen bytes in str, excluding the null terminator. That's it, that's the job. She's a counter, not a fighter π
If you need the length of a UTF-8 string, bestie, consider using SDL_utf8strnlen() instead. different function, different vibe, iykyk.
π FUNCTION PARAMETERS π
strβ the null-terminated string you want to read. Must not beNULLβ like, genuinely, don't. π«maxlenβ the maximum amount of bytes to count. she stops here, periodt.
β RETURN VALUE β
Returns the length (in bytes, excluding the null terminator) of src, but never more than maxlen. yes the page really says src there and not str β not me noticing that π we simply respect the lore.
π₯ THREAD SAFETY π₯
It is safe to call this function from any thread. go forth and thread it, queen π
π AVAILABILITY π
This function is available since SDL 3.2.0. if you're on something older, sorry babe π
π SEE ALSO π
Simple Directmedia Layer πΈ SDL 3.4.18 πΈ SDL_strnlen(3) β mwah, that's the whole page, ty for coming to my ted talk, go count some bytes πβ¨ππ¦
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms