diff options
author | Akashi, Takahiro <takahiro.akashi@linaro.org> | 2018-12-14 19:10:38 +0900 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2019-02-13 09:40:05 +0100 |
commit | 2a3537ae2272d9699312a0855a7b72472d1719c5 (patch) | |
tree | 470f1262db074eb6beb340bd4b6742d23b1bdbde /lib/charset.c | |
parent | 2859f446b081db62336c32a832af026d37ab00b4 (diff) | |
download | u-boot-2a3537ae2272d9699312a0855a7b72472d1719c5.tar.gz u-boot-2a3537ae2272d9699312a0855a7b72472d1719c5.tar.bz2 u-boot-2a3537ae2272d9699312a0855a7b72472d1719c5.zip |
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>
Diffstat (limited to 'lib/charset.c')
-rw-r--r-- | lib/charset.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/charset.c b/lib/charset.c index 10557b9e75..5e349ed5ee 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -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) { |