summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2021-02-13 13:14:02 -0500
committerPeter Jones <pjones@redhat.com>2021-02-13 13:24:06 -0500
commitcf7260d432e789ae93947c245af1f4fdda799ac9 (patch)
tree7cd30d78960b4325782bf34d06884dd604b345a9 /include
parentb0a2ea0caa2ac501ceb96c46df4fc0d4eb6ec891 (diff)
downloadefi-boot-shim-cf7260d432e789ae93947c245af1f4fdda799ac9.tar.gz
efi-boot-shim-cf7260d432e789ae93947c245af1f4fdda799ac9.zip
add an ascii strndup() implementation.
Signed-off-by: Peter Jones <pjones@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/str.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/str.h b/include/str.h
index ea03ee3f..baa260e3 100644
--- a/include/str.h
+++ b/include/str.h
@@ -45,6 +45,24 @@ strcata(CHAR8 *dest, const CHAR8 *src)
static inline
__attribute__((unused))
CHAR8 *
+strndupa(const CHAR8 * const src, const UINTN srcmax)
+{
+ UINTN len;
+ CHAR8 *news = NULL;
+
+ if (!src || !srcmax)
+ return news;
+
+ len = strnlena(src, srcmax);
+ news = AllocateZeroPool(len);
+ if (news)
+ strncpya(news, src, len);
+ return news;
+}
+
+static inline
+__attribute__((unused))
+CHAR8 *
translate_slashes(CHAR8 *out, const char *str)
{
int i;