kstrdup(9)
π kstrdup(9) π
okay bestie, so this is a page from the Kernel API Manual and it's literally the whole kstrdup vibe. stay with me, it's short and it slays.
β¨ NAME β¨
kstrdup β allocate space for and copy an existing string
like, it makes room and then copies the string into it. the whole package. π
πΈ SYNOPSIS πΈ
char * kstrdup (const char *s , gfp_t gfp );
π¦ ARGUMENTS π¦
sβ the string to duplicate. your main character string, the one getting copied πgfpβ the GFP mask used in thekmalloccall when allocating memory. yes the memory allocation is happening, and this is the mask it uses, no cap
β RETURN β
it hands you a newly allocated copy of s β iconic β or NULL if something went wrong π in case of error, it's NULL.
fr fr check it. NULL is a real possible answer here, don't just assume you got a string back and go dereferencing it, bestie π
π₯ SEE ALSO π₯
this list is lowkey long but every single one of these is invited to the party, no gatekeeping:
- Kernel file
./mm/util.c kfree_const(9)__kmemdup_nul(9)kstrdup_const(9)kstrndup(9)kmemdup(9)kmemdup_array(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 page!! π«Ά this whole thing lives under ./mm, dated October 2026, and it's titled kstrdup(9) β go forth and duplicate your strings responsibly, bestie, mwah πβ¨π
π¦ 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