blob: 0d65ce304300ae9b787c01826ca1e3cc33f03d96 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
|
#include "memory.h"
wchar_t *wcsndup(wchar_t const *restrict string, size_t max_lenght)
{
size_t lenght = wcsnlen(string, max_lenght) + 1;
wchar_t *duplicate = reallocarray(NULL, lenght, sizeof *duplicate);
if (duplicate != NULL)
wmemcpy(duplicate, string, lenght);
return duplicate;
}
|