kunit_kstrdup_const(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– kunit_kstrdup_const(9) πŸ’–

okay so this is a page from the Kernel API Manual, and it's about kunit_kstrdup_const β€” the function that conditionally duplicates a string into a test managed allocation. bestie, it's giving "I only duplicate when I absolutely have to" energy ✨


πŸŽ€ NAME πŸŽ€

kunit_kstrdup_const β€” Conditionally duplicates a string into a test managed allocation. no cap, that's the whole name vibe πŸ’…

✨ SYNOPSIS ✨

const char * kunit_kstrdup_const (struct kunit *test , const char *str , gfp_t gfp );

🌸 ARGUMENTS 🌸

  • test β€” The test context object. it's your test's little home base, the main character of the test world 🫢
  • str β€” The NULL-terminated string to duplicate. yes, the whole string, NULL-terminated and everything, not playing games πŸ’–
  • gfp β€” flags passed to underlying kmalloc. those flags go straight to kmalloc, iykyk πŸ¦‹

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea: it calls kunit_kstrdup only if str is not in the rodata section. that's the "conditionally" part, and it's lowkey important πŸ‘‘

⚠️ bestie, listen: this thing must be freed with kunit_kfree_const β€” not kunit_kfree. do not mix them up, fr fr 😭

also see kstrdup_const and kunit_kmalloc_array for more information, because those are the related lore drops πŸ“šβœ¨

🌈 SEE ALSO 🌈

Kernel file ./include/kunit/test.h:


okay bye bestie πŸ‘‹ this page's source is ./include/kunit, it's from the Kernel API Manual, dated October 2026, and the title is kunit_kstrdup_const(9). slay, stay hydrated, and free your strings with the right function πŸ’–βœ¨

πŸ“¦ where this page comes from