1199767fToomas Soome/*
2199767fToomas Soome * Copyright (c) 1988, 1993
3199767fToomas Soome *	The Regents of the University of California.  All rights reserved.
4199767fToomas Soome *
5199767fToomas Soome * Redistribution and use in source and binary forms, with or without
6199767fToomas Soome * modification, are permitted provided that the following conditions
7199767fToomas Soome * are met:
8199767fToomas Soome * 1. Redistributions of source code must retain the above copyright
9199767fToomas Soome *    notice, this list of conditions and the following disclaimer.
10199767fToomas Soome * 2. Redistributions in binary form must reproduce the above copyright
11199767fToomas Soome *    notice, this list of conditions and the following disclaimer in the
12199767fToomas Soome *    documentation and/or other materials provided with the distribution.
131974da4Toomas Soome * 3. Neither the name of the University nor the names of its contributors
14199767fToomas Soome *    may be used to endorse or promote products derived from this software
15199767fToomas Soome *    without specific prior written permission.
16199767fToomas Soome *
17199767fToomas Soome * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18199767fToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19199767fToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20199767fToomas Soome * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21199767fToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22199767fToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23199767fToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24199767fToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25199767fToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26199767fToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27199767fToomas Soome * SUCH DAMAGE.
28199767fToomas Soome */
29199767fToomas Soome
30199767fToomas Soome#include <sys/cdefs.h>
31199767fToomas Soome
32199767fToomas Soome#include "stand.h"
33199767fToomas Soome#include <stddef.h>
34199767fToomas Soome#include <string.h>
35199767fToomas Soome
36199767fToomas Soomechar *
370384eafToomas Soomestrdup(const char *str)
38199767fToomas Soome{
39199767fToomas Soome	size_t len;
40199767fToomas Soome	char *copy = NULL;
41199767fToomas Soome
42199767fToomas Soome	if (str != NULL) {
430384eafToomas Soome		len = strlen(str) + 1;
440384eafToomas Soome		if ((copy = malloc(len)) == NULL)
450384eafToomas Soome			return (NULL);
460384eafToomas Soome		memcpy(copy, str, len);
47199767fToomas Soome	}
48199767fToomas Soome	return (copy);
49199767fToomas Soome}
50