kmemdup_array(9)
π 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:
kfree_const(9)__kmemdup_nul(9)kstrdup(9)kstrdup_const(9)kstrndup(9)kmemdup(9)kvmemdup(9)kmemdup_nul(9)memdup_user(9)vmemdup_user(9)strndup_user(9)memdup_user_nul(9)randomize_page(9)__account_locked_vm(9)account_locked_vm(9)__vmalloc_array(9)vmalloc_array(9)__vcalloc(9)vcalloc(9)folio_mapping(9)folio_copy(9)get_cmdline(9)mem_dump_obj(9)compat_set_desc_from_vma(9)__compat_vma_mmap(9)compat_vma_mmap(9)snapshot_page(9)mmap_action_prepare(9)mmap_action_complete(9)folio_pte_batch(9)page_range_contiguous(9)
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
- 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