xmalloc: add xwcsdup()

This commit is contained in:
Daniel Eklöf 2020-10-09 19:43:04 +02:00
parent c66ad118b7
commit 8aba25a477
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 9 additions and 0 deletions

View file

@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <syslog.h>
#include "xmalloc.h"
@ -54,6 +55,12 @@ xstrdup(const char *str)
return check_alloc(strdup(str));
}
wchar_t *
xwcsdup(const wchar_t *str)
{
return check_alloc(wcsdup(str));
}
char *
xstrndup(const char *str, size_t n)
{

View file

@ -1,6 +1,7 @@
#pragma once
#include <stddef.h>
#include <wchar.h>
#include "macros.h"
void *xmalloc(size_t size) XMALLOC;
@ -9,3 +10,4 @@ void *xrealloc(void *ptr, size_t size);
char *xstrdup(const char *str) XSTRDUP;
char *xstrndup(const char *str, size_t n) XSTRDUP;
char *xasprintf(const char *format, ...) PRINTF(1) XMALLOC;
wchar_t *xwcsdup(const wchar_t *str) XSTRDUP;