kmemdup_array(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… kmemdup_array β€” Kernel API Manual, bestie edition ✨

okay so real talk, this one's from the Kernel API Manual and it's literally called kmemdup_array(9) β€” say that five times fast 🫢 it's giving "copy my whole array, please" and honestly? iconic.


✨ NAME ✨

kmemdup_array β€” duplicate a given array. that's it. that's the whole vibe. copy, paste, slay πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

void * kmemdup_array (const void *src , size_t count , size_t
       element_size , gfp_t gfp );

like, look at her. four lil arguments and a void * return. main character energy fr fr ✨


🌸 ARGUMENTS 🌸

  • src β€” the array you wanna duplicate. the original. the blueprint. the source material, if you will πŸ’–
  • count β€” how many elements you're copying out of that array. yes, you gotta say the number, no mind-reading allowed πŸ™ˆ
  • element_size β€” the size of each element in the array. because the kernel needs to know how chunky each lil guy is 🧚
  • gfp β€” the GFP mask to use. that's the allocation-flags situation, iykyk πŸ¦‹

πŸ”₯ RETURN πŸ”₯

you get back the duplicated array of src β€” or NULL if something went sideways (error vibes 😭). and heads up bestie, the result is physically contiguous, no cap. when you're done with it, hit it with kfree to free it. don't forget. please. 🫢


πŸ’œ SEE ALSO πŸ’œ

Kernel file ./mm/util.c β€” that's where the magic lives, go read it πŸŽ€

then the whole friend group:


and that's the whole page, no notes πŸ’…

cute lil sign-off: this one lives under ./mm and it's dated October 2026 β€” so yeah, she's from the future, we stan a forward-thinking queen πŸ‘‘πŸŒˆ

periodt. πŸ¦‹βœ¨

πŸ“¦ where this page comes from