match_string(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’« match_string(9) β€” Kernel API Manual πŸ’«

okay so bestie, today we're learning about match_string, and honestly? she's a little icon of the kernel string-helper world πŸŽ€


🌸 NAME 🌸

match_string β€” matches given string in an array. that's it, that's the whole job, and she does it flawlessly πŸ’…


✨ SYNOPSIS ✨

int match_string (const char * const *array , size_t n , const char
*string );

literally the whole signature, copied exactly, no cap πŸ”₯


πŸ¦‹ ARGUMENTS πŸ¦‹

  • array β€” array of strings. yes, the place where all your little string besties live 🫢
  • n β€” number of strings in the array, or -1 for NULL terminated arrays 🌈
  • string β€” string to match with. the one we're out here looking for πŸ‘‘

πŸ’– DESCRIPTION πŸ’–

This routine will look for a string in an array of strings up to the n-th element in the array or until the first NULL element. so basically she's scrolling the group chat looking for that one specific message 😭

Historically the value of -1 for n, was used to search in arrays that are NULL terminated. that's the og vibe, iykyk. However, the function does not make a distinction when finishing the search: either n elements have been compared OR the first NULL element was found. so like, she stops at whichever comes first β€” no favorites, no drama, she just ends the search the same way either way ✨

🧚 real talk: don't assume she knows why she stopped. both endings look identical from the outside, bestie.

⭐ RETURN ⭐

index of a string in the array if matches, or -EINVAL otherwise. slay when it hits, -EINVAL when it doesn't πŸ’€


πŸ“ SEE ALSO πŸ“

Kernel file ./lib/string_helpers.c β€” plus the whole friend group, and we love them all:


that's the whole page, bestie β€” no notes, she ate πŸ’…βœ¨

source: ./lib Β· version/date: October 2026 Β· ok bye ily, go read the source and hydrate πŸŒΈπŸ«ΆπŸ’œ

πŸ“¦ where this page comes from