Blame src/u16_wcsdup.c

397cb1
/*******************************************************************/
397cb1
/*  u16ports: u16 variants of wide character string functions.     */
397cb1
/*  Copyright (C) 2017  Z. Gilboa                                  */
397cb1
/*  Released under the Standard MIT License; see COPYING.U16PORTS. */
397cb1
/*******************************************************************/
397cb1
397cb1
#include <stdint.h>
397cb1
#include <stdlib.h>
397cb1
#include <string.h>
397cb1
#include <u16ports/u16ports.h>
397cb1
397cb1
uint16_t * u16_wcsdup(const uint16_t * src)
397cb1
{
397cb1
	uint16_t * dst;
397cb1
	size_t     len;
397cb1
397cb1
	len = sizeof(uint16_t) * (1 + u16_wcslen(src));
397cb1
397cb1
	if (!(dst = malloc(len)))
397cb1
		return 0;
397cb1
397cb1
	memcpy(dst,src,len);
397cb1
397cb1
	return dst;
397cb1
}