aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/linux/string_helpers.h
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2023-08-04 17:39:07 +0300
committerStephen Boyd <sboyd@kernel.org>2023-08-04 18:21:50 -0700
commit045ad46441a1cf2ff358af0126f8c57f337804fa (patch)
tree0d8745d448f22648486c123c18e055aef20be105 /include/linux/string_helpers.h
parentLinux 6.5-rc1 (diff)
downloadwireguard-linux-045ad46441a1cf2ff358af0126f8c57f337804fa.tar.xz
wireguard-linux-045ad46441a1cf2ff358af0126f8c57f337804fa.zip
lib/string_helpers: Add kstrdup_and_replace() helper
Duplicate a NULL-terminated string and replace all occurrences of the old character with a new one. In other words, provide functionality of kstrdup() + strreplace(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20230804143910.15504-2-andriy.shevchenko@linux.intel.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Diffstat (limited to 'include/linux/string_helpers.h')
-rw-r--r--include/linux/string_helpers.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h
index 789ab30045da..9d1f5bb74dd5 100644
--- a/include/linux/string_helpers.h
+++ b/include/linux/string_helpers.h
@@ -109,6 +109,8 @@ char *kstrdup_quotable(const char *src, gfp_t gfp);
char *kstrdup_quotable_cmdline(struct task_struct *task, gfp_t gfp);
char *kstrdup_quotable_file(struct file *file, gfp_t gfp);
+char *kstrdup_and_replace(const char *src, char old, char new, gfp_t gfp);
+
char **kasprintf_strarray(gfp_t gfp, const char *prefix, size_t n);
void kfree_strarray(char **array, size_t n);