]> git.proxmox.com Git - efi-boot-shim.git/commitdiff
add an ascii strndup() implementation.
authorPeter Jones <pjones@redhat.com>
Sat, 13 Feb 2021 18:14:02 +0000 (13:14 -0500)
committerPeter Jones <pjones@redhat.com>
Sat, 13 Feb 2021 18:24:06 +0000 (13:24 -0500)
Signed-off-by: Peter Jones <pjones@redhat.com>
include/str.h

index ea03ee3feb3a17f411e9a68fada9f4db48f834f3..baa260e33f75042feaa3ffb04d46463edad2873d 100644 (file)
@@ -42,6 +42,24 @@ strcata(CHAR8 *dest, const CHAR8 *src)
        return dest;
 }
 
+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 *