1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-01 08:42:12 +02:00

lib: add u16_strcpy/strdup functions

Add u16_strcpy() and u16_strdup(). The latter function will be
used later in implementing efi HII database protocol.

Signed-off-by: Akashi Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
Akashi, Takahiro
2018-12-14 19:10:38 +09:00
committed by Alexander Graf
parent 2859f446b0
commit 2a3537ae22
2 changed files with 52 additions and 0 deletions

View File

@@ -349,6 +349,35 @@ size_t u16_strnlen(const u16 *in, size_t count)
return i;
}
u16 *u16_strcpy(u16 *dest, const u16 *src)
{
u16 *tmp = dest;
for (;; dest++, src++) {
*dest = *src;
if (!*src)
break;
}
return tmp;
}
u16 *u16_strdup(const u16 *src)
{
u16 *new;
if (!src)
return NULL;
new = malloc((u16_strlen(src) + 1) * sizeof(u16));
if (!new)
return NULL;
u16_strcpy(new, src);
return new;
}
/* Convert UTF-16 to UTF-8. */
uint8_t *utf16_to_utf8(uint8_t *dest, const uint16_t *src, size_t size)
{