add an ascii strndup() implementation.

Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
Peter Jones 2021-02-13 13:14:02 -05:00
parent b0a2ea0caa
commit cf7260d432

View 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 *