diff --git a/include/xfuncs.h b/include/xfuncs.h index 7885a6e..e3f120a 100644 --- a/include/xfuncs.h +++ b/include/xfuncs.h @@ -3,6 +3,7 @@ #include #include +#include void *xmalloc(size_t size); void *xrealloc(void *ptr, size_t size); @@ -14,4 +15,8 @@ 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 */ diff --git a/lib/xfuncs.c b/lib/xfuncs.c index 6111f6d..152081c 100644 --- a/lib/xfuncs.c +++ b/lib/xfuncs.c @@ -22,6 +22,7 @@ #include #include #include +#include void *xmalloc(size_t size) { @@ -127,3 +128,33 @@ 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);