mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 06/10] lib: add wchar strdup
Date: Tue,  4 Nov 2014 10:42:52 +0100	[thread overview]
Message-ID: <1415094176-26435-6-git-send-email-l.stach@pengutronix.de> (raw)
In-Reply-To: <1415094176-26435-1-git-send-email-l.stach@pengutronix.de>

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 include/wchar.h |  2 ++
 lib/wchar.c     | 16 ++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/include/wchar.h b/include/wchar.h
index 80dcd81bf442..702d8e239a7c 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -5,6 +5,8 @@
 
 typedef u16 wchar_t;
 
+wchar_t *strdup_wchar(const wchar_t *src);
+
 char *strcpy_wchar_to_char(char *dst, const wchar_t *src);
 
 wchar_t *strcpy_char_to_wchar(wchar_t *dst, const char *src);
diff --git a/lib/wchar.c b/lib/wchar.c
index 6368a019941e..b2e9e7545b1f 100644
--- a/lib/wchar.c
+++ b/lib/wchar.c
@@ -31,6 +31,22 @@ size_t wcslen(const wchar_t *s)
 	return len;
 }
 
+wchar_t *strdup_wchar(const wchar_t *src)
+{
+	int len = wcslen(src);
+	wchar_t *tmp, *dst;
+
+	if (!(dst = malloc((len + 1) * sizeof(wchar_t))))
+		return NULL;
+
+	tmp = dst;
+
+	while ((*dst++ = *src++))
+		/* nothing */;
+
+	return tmp;
+}
+
 char *strcpy_wchar_to_char(char *dst, const wchar_t *src)
 {
 	char *ret = dst;
-- 
2.1.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2014-11-04  9:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-04  9:42 [PATCH 01/10] efi: add proper reset hook Lucas Stach
2014-11-04  9:42 ` [PATCH 02/10] efi: add Barebox GUID Lucas Stach
2014-11-05  7:21   ` Sascha Hauer
2014-11-05  9:03     ` Lucas Stach
2014-11-04  9:42 ` [PATCH 03/10] fs: efivar: cosmetic changes Lucas Stach
2014-11-04  9:42 ` [PATCH 04/10] fs: efivar: switch to standard list implementation Lucas Stach
2014-11-04  9:42 ` [PATCH 05/10] fs: efivar: move variable discovery into probe Lucas Stach
2014-11-04  9:42 ` Lucas Stach [this message]
2014-11-04  9:42 ` [PATCH 07/10] fs: efivar: preserve more info in inode Lucas Stach
2014-11-04  9:42 ` [PATCH 08/10] fs: efivar: don't store attributes in file Lucas Stach
2014-11-04  9:42 ` [PATCH 09/10] fs: efivar: implement write support Lucas Stach
2014-11-04  9:42 ` [PATCH 10/10] efi: mount efivarfs by default if enabled Lucas Stach
2014-11-05  7:21 ` [PATCH 01/10] efi: add proper reset hook Sascha Hauer
2014-11-05  9:00   ` Lucas Stach

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=1415094176-26435-6-git-send-email-l.stach@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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