From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/6] lib: add u16_strcpy/strdup functions
Date: Fri, 2 Nov 2018 09:12:31 +0900 [thread overview]
Message-ID: <20181102001230.GN11663@linaro.org> (raw)
In-Reply-To: <b01c799d-74b2-801a-2cc8-195b363a188f@gmx.de>
On Thu, Nov 01, 2018 at 07:10:59AM +0100, Heinrich Schuchardt wrote:
> On 11/01/2018 05:45 AM, AKASHI Takahiro wrote:
> > From: "Akashi Takahiro" <takahiro.akashi@linaro.org>
> >
> > 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>
> > ---
> > include/charset.h | 18 ++++++++++++++++++
> > lib/charset.c | 29 +++++++++++++++++++++++++++++
> > 2 files changed, 47 insertions(+)
> >
> > diff --git a/include/charset.h b/include/charset.h
> > index 4d45e246e515..5807f02b1a04 100644
> > --- a/include/charset.h
> > +++ b/include/charset.h
> > @@ -191,6 +191,24 @@ size_t u16_strlen(const u16 *in);
> > */
> > size_t u16_strnlen(const u16 *in, size_t count);
> >
> > +/* TODO: add descriptions */
>
> You could use the descriptions below.
Thanks. Actually I forgot to delete this line :)
I will take your description anyway.
-Takahiro Akashi
> > +/**
> > + * u16_strcpy() - copy u16 string
>
> Copy u16 string pointed to by src, including terminating null word, to
> the buffer pointed to by dest.
>
> > + *
> > + * @dest: destination buffer
> > + * @src: source buffer (null terminated)
> > + * Return: 'dest' address
> > + */
> > +u16 *u16_strcpy(u16 *dest, const u16 *src);
> > +
> > +/**
> > + * u16_strdup() - duplicate u16 string
>
> Copy u16 string pointed to by src, including terminating null word, to a
> newly allocated buffer.
>
> > + *
> > + * @src: source buffer (null terminated)
> > + * Return: allocated new buffer on success, NULL on failure
> > + */
> > +u16 *u16_strdup(const u16 *src);
> > +
> > /**
> > * utf16_to_utf8() - Convert an utf16 string to utf8
> > *
> > diff --git a/lib/charset.c b/lib/charset.c
> > index 10557b9e753d..5e349ed5ee45 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)
> > {
> >
>
> For everything I added to charset.c I implemented tests in
> test/unicode_ut.c.
>
> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
next prev parent reply other threads:[~2018-11-02 0:12 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-01 4:40 [U-Boot] [PATCH 0/6] efi_loader: add HII database protocol AKASHI Takahiro
2018-11-01 4:45 ` [U-Boot] [PATCH 1/6] lib: add u16_strcpy/strdup functions AKASHI Takahiro
2018-11-01 6:10 ` Heinrich Schuchardt
2018-11-02 0:12 ` AKASHI Takahiro [this message]
2018-11-01 4:47 ` [U-Boot] [PATCH 2/6] efi_loader: Initial HII database protocols AKASHI Takahiro
2018-11-01 4:47 ` [U-Boot] [PATCH 3/6] efi: hii: add guid package support AKASHI Takahiro
2018-11-01 4:47 ` [U-Boot] [PATCH 4/6] efi: hii: add keyboard layout " AKASHI Takahiro
2018-11-01 4:47 ` [U-Boot] [PATCH 5/6] efi: hii: add HII config routing/access protocols AKASHI Takahiro
2018-11-01 4:47 ` [U-Boot] [PATCH 6/6] efi_selftest: add HII database protocols test AKASHI Takahiro
2018-11-01 7:33 ` Heinrich Schuchardt
2018-11-02 0:55 ` AKASHI Takahiro
2018-11-02 8:12 ` Heinrich Schuchardt
2018-11-01 7:09 ` [U-Boot] [PATCH 2/6] efi_loader: Initial HII database protocols Heinrich Schuchardt
2018-11-02 2:03 ` AKASHI Takahiro
2018-11-01 7:39 ` Heinrich Schuchardt
2018-11-02 0:32 ` AKASHI Takahiro
2018-11-02 8:15 ` Heinrich Schuchardt
2018-11-01 8:42 ` Heinrich Schuchardt
2018-11-02 0:17 ` AKASHI Takahiro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181102001230.GN11663@linaro.org \
--to=takahiro.akashi@linaro.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox