1149011Stjr/*- 2149011Stjr * Copyright (c) 2005 Tim J. Robbins. 3149011Stjr * All rights reserved. 4149011Stjr * 5149011Stjr * Redistribution and use in source and binary forms, with or without 6149011Stjr * modification, are permitted provided that the following conditions 7149011Stjr * are met: 8149011Stjr * 1. Redistributions of source code must retain the above copyright 9149011Stjr * notice, this list of conditions and the following disclaimer. 10149011Stjr * 2. Redistributions in binary form must reproduce the above copyright 11149011Stjr * notice, this list of conditions and the following disclaimer in the 12149011Stjr * documentation and/or other materials provided with the distribution. 13149011Stjr * 14149011Stjr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15149011Stjr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16149011Stjr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17149011Stjr * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18149011Stjr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19149011Stjr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20149011Stjr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21149011Stjr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22149011Stjr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23149011Stjr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24149011Stjr * SUCH DAMAGE. 25149011Stjr */ 26149011Stjr 27149011Stjr#include <sys/cdefs.h> 28149011Stjr__FBSDID("$FreeBSD: releng/10.2/lib/libc/string/wcsdup.c 149011 2005-08-13 05:54:33Z tjr $"); 29149011Stjr 30149011Stjr#include <stdlib.h> 31149011Stjr#include <wchar.h> 32149011Stjr 33149011Stjrwchar_t * 34149011Stjrwcsdup(const wchar_t *s) 35149011Stjr{ 36149011Stjr wchar_t *copy; 37149011Stjr size_t len; 38149011Stjr 39149011Stjr len = wcslen(s) + 1; 40149011Stjr if ((copy = malloc(len * sizeof(wchar_t))) == NULL) 41149011Stjr return (NULL); 42149011Stjr return (wmemcpy(copy, s, len)); 43149011Stjr} 44