MEMCCHR(9)

πŸ’– MEMCCHR(9) πŸ’–

okay bestie, welcome to the Kernel Developer's Manual β€” yes we're in the kernel section, section 9, we're that girl now. this one's about memcchr, and she is lowkey the icon of "find me the one that's DIFFERENT" πŸ¦‹


✨ NAME ✨

memcchr β€” locate the complement of a byte in byte string

like. she finds the byte that's not the one you asked for. the contrarian queen. the main character who refuses to match. periodt πŸ’…


🌸 SYNOPSIS 🌸

#include <sys/libkern.h>

void *
memcchr(const void *b, int c, size_t len);

πŸ’œ DESCRIPTION πŸ’œ

so the way that memcchr() works is: it locates the first occurrence of a byte unequal to c (converted to an unsigned char, bestie, don't forget the conversion πŸ‘‘) in the string b.

that's it. that's the whole vibe. everybody else is out here looking for the byte that matches, and memcchr() said "no πŸ’€ i want the one that doesn't." iconic behaviour, honestly.


πŸŽ€ RETURN VALUES πŸŽ€

memcchr() returns a pointer to the byte located 🫢 β€” or NULL if no such byte exists within len bytes.

ngl if you get NULL back it's giving "she searched the whole thing and everyone matched, no rebels found." handle it, don't just dereference it like a menace 😭

🌈 SEE ALSO 🌈

(the original, the classic, the one who finds the matching byte. memcchr is her chaotic little sister fr fr ✨)


⭐ HISTORY ⭐

the memcchr() function first appeared in FreeBSD 10.0. a debut. a moment. we love a queen with lore πŸ’–


and that's the whole page, bestie!! 🧚 this one came from the Debian edition of the manual, dated January 1, 2012 β€” so yeah, vintage, but the energy is timeless. go forth and find your odd one out πŸ“βœ¨

πŸ“¦ where this page comes from