strtomem_pad(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… strtomem_pad(9) β€” the kernel API manual, bestie edition πŸŽ€

okay so this is strtomem_pad(9), and honestly? she's that girl. let's get into it ✨


🌸 NAME 🌸

strtomem_pad β€” copy a NUL-terminated string into a buffer that is not NUL-terminated. yes, you read that right, no cap πŸ’…


✨ SYNOPSIS ✨

strtomem_pad (dest , src , pad );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • dest β€” pointer to the destination character array, and it's marked as __nonstring (iykyk). she's just built different, she does not do NUL termination 🫢
  • src β€” pointer to a NUL-terminated string. the source does have her little terminator, so bestie's got bounds to check against πŸ’–
  • pad β€” the padding character used to fill any remaining bytes of dest after the copy. filler queen πŸ‘‘

πŸ”₯ DESCRIPTION πŸ”₯

so this one is a replacement for strncpy uses where the destination is not a NUL-terminated string β€” but (and this is the iconic part) with bounds checking on the source size and an explicit padding character. obsessed.

if padding is not required, use strtomem instead. it's giving "less is more" 🌈

⚠️ note that the size of dest is not an argument β€” because the length of dest must be discoverable by the compiler. literally non-negotiable, the compiler has to know, periodt πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./include/linux/string.h, plus the whole friend group: memdup_array_user(9), vmemdup_array_user(9), strscpy(9), strscpy_pad(9), mem_is_zero(9), sysfs_match_string(9), memzero_explicit(9), kbasename(9), strtomem(9), memtostr(9), memtostr_pad(9), memset_after(9), memset_startat(9), str_has_prefix(9), strstarts(9), strends(9) πŸ§šπŸ’œ


and that's the whole vibe check πŸŽ€ this one lives over in ./include/linux, straight from the October 2026 crew β€” mwah, slay, go forth and pad responsibly βœ¨πŸ’–πŸ¦‹

πŸ“¦ where this page comes from