9
0
Fork 0

xfuncs: add wrapper for wchar strdup functions

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Michael Olbrich 2015-07-17 21:22:35 +02:00 committed by Sascha Hauer
parent 773be2a168
commit 17e6044074
2 changed files with 36 additions and 0 deletions

View File

@ -3,6 +3,7 @@
#include <linux/types.h>
#include <stdarg.h>
#include <wchar.h>
void *xmalloc(size_t size);
void *xrealloc(void *ptr, size_t size);
@ -14,4 +15,8 @@ void* xmemdup(const void *orig, size_t size);
char *xasprintf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2)));
char *xvasprintf(const char *fmt, va_list ap);
wchar_t *xstrdup_wchar(const wchar_t *src);
wchar_t *xstrdup_char_to_wchar(const char *src);
char *xstrdup_wchar_to_char(const wchar_t *src);
#endif /* __XFUNCS_H */

View File

@ -22,6 +22,7 @@
#include <common.h>
#include <malloc.h>
#include <module.h>
#include <wchar.h>
void *xmalloc(size_t size)
{
@ -127,3 +128,33 @@ char *xasprintf(const char *fmt, ...)
return p;
}
EXPORT_SYMBOL(xasprintf);
wchar_t *xstrdup_wchar(const wchar_t *s)
{
wchar_t *p = strdup_wchar(s);
if (!p)
panic("ERROR: out of memory\n");
return p;
}
EXPORT_SYMBOL(xstrdup_wchar);
wchar_t *xstrdup_char_to_wchar(const char *s)
{
wchar_t *p = strdup_char_to_wchar(s);
if (!p)
panic("ERROR: out of memory\n");
return p;
}
EXPORT_SYMBOL(xstrdup_char_to_wchar);
char *xstrdup_wchar_to_char(const wchar_t *s)
{
char *p = strdup_wchar_to_char(s);
if (!p)
panic("ERROR: out of memory\n");
return p;
}
EXPORT_SYMBOL(xstrdup_wchar_to_char);