summaryrefslogtreecommitdiff
path: root/lib/string_helpers.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2023-10-03 09:32:25 +0200
committerIngo Molnar <mingo@kernel.org>2023-10-03 09:32:25 +0200
commitde80193308f43d3ae52cd3561e8ba77cd1437311 (patch)
tree3960ff42c407370dfd8c114e5b828bdece9cf425 /lib/string_helpers.c
parent54aee5f15b83437f23b2b2469bcf21bdd9823916 (diff)
parent8a749fd1a8720d4619c91c8b6e7528c0a355c0aa (diff)
Merge tag 'v6.6-rc4' into perf/core, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'lib/string_helpers.c')
-rw-r--r--lib/string_helpers.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/string_helpers.c b/lib/string_helpers.c
index d3b1dd718daf..9982344cca34 100644
--- a/lib/string_helpers.c
+++ b/lib/string_helpers.c
@@ -719,6 +719,21 @@ char *kstrdup_quotable_file(struct file *file, gfp_t gfp)
}
EXPORT_SYMBOL_GPL(kstrdup_quotable_file);
+/*
+ * Returns duplicate string in which the @old characters are replaced by @new.
+ */
+char *kstrdup_and_replace(const char *src, char old, char new, gfp_t gfp)
+{
+ char *dst;
+
+ dst = kstrdup(src, gfp);
+ if (!dst)
+ return NULL;
+
+ return strreplace(dst, old, new);
+}
+EXPORT_SYMBOL_GPL(kstrdup_and_replace);
+
/**
* kasprintf_strarray - allocate and fill array of sequential strings
* @gfp: flags for the slab allocator