devm_kmemdup_const(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… devm_kmemdup_const β€” kernel API manual, but make it make sense ✨

okay so bestie, welcome to devm_kmemdup_const(9), straight out of the Kernel API Manual πŸŽ€ this one is short, it's sweet, and it's giving "manager energy" β€” because it doesn't just duplicate your memory, it manages it for you too. no cap 🫢


✨ NAME ✨

devm_kmemdup_const β€” conditionally duplicate and manage a region of memory πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

const void * devm_kmemdup_const (struct device *dev , const void *src ,
size_t len , gfp_t gfp );

🌸 ARGUMENTS 🌸

  • dev β€” the device this memory belongs to, like the whole thing is registered under its name πŸ‘‘
  • src β€” the memory region to duplicate, the og copy, the blueprint πŸŽ€
  • len β€” memory region length, (yes the comma is canon, don't come for me) πŸ“
  • gfp β€” the GFP mask to use, that's the flavour of allocation, iykyk 🌈

πŸ’€ RETURN πŸ’€

it hands you back the source address if that address is in .rodata β€” like, it literally just points at the og constant and goes "that's already perfect, why would I copy it" πŸ’…

otherwise? it falls back to the return value of kmemdup πŸ” so you get a fresh copy, no cap.

lowkey important: the "conditionally" in the name is doing real work here fr fr β€” .rodata means no duplication, everything else means kmemdup city ✨

πŸ”₯ SEE ALSO πŸ”₯

Kernel file ./drivers/base/devres.c β€” the whole devres family, and honestly bestie, it's a whole friend group 🫢


and that's the whole page, bestie, you ate that πŸ’…βœ¨

sign-off szn πŸŽ€: this icon lives in ./drivers/base, the date on the tin is October 2026, and the source/version is the Kernel API Manual itself β€” go forth and duplicate responsibly πŸ‘‘πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from