strtomem(9)
π strtomem(9) π
okay so welcome to the Kernel API Manual corner, bestie β this is the page for strtomem(9), and it's lowkey iconic for one specific job. β¨
πΈ NAME πΈ
strtomem β copy a NUL-terminated string to a non-NUL-terminated buffer. no cap, that's the whole serve. π
β¨ SYNOPSIS β¨
strtomem (dest , src );
π ARGUMENTS π
destβ pointer of destination character array (marked as__nonstring) π«Άsrcβ pointer to a NUL-terminated string π
π DESCRIPTION π
This is a replacement for strncpy uses where the destination is not a NUL-terminated string, but with bounds checking on the source size, and without trailing padding. it's giving "safe copy, no extra fluff." π
If padding is required, use strtomem_pad instead β that's the padded bestie. π
note that the size ofdestis not an argument, as the length ofdestmust be discoverable by the compiler. literally the compiler has to be able to figure it out, so don't come for this function with mystery sizes. π
π¦ SEE ALSO π¦
Kernel file ./include/linux/string.h is the home base, and these linked besties are all part of the crew:
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_pad(9)memtostr(9)memtostr_pad(9)memset_after(9)memset_startat(9)str_has_prefix(9)strstarts(9)strends(9)
this page is brought to you by ./include/linux, dated October 2026, and it's serving strtomem(9) energy from the source to the very end. πβ¨π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms