12949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project/*
22949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * Copyright (c) 1988, 1993
32949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project *	The Regents of the University of California.  All rights reserved.
42949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project *
52949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * Redistribution and use in source and binary forms, with or without
62949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * modification, are permitted provided that the following conditions
72949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * are met:
82949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * 1. Redistributions of source code must retain the above copyright
92949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project *    notice, this list of conditions and the following disclaimer.
102949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * 2. Redistributions in binary form must reproduce the above copyright
112949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project *    notice, this list of conditions and the following disclaimer in the
122949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project *    documentation and/or other materials provided with the distribution.
132949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * 3. All advertising materials mentioning features or use of this software
142949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project *    must display the following acknowledgement:
152949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project *	This product includes software developed by the University of
162949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project *	California, Berkeley and its contributors.
172949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * 4. Neither the name of the University nor the names of its contributors
182949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project *    may be used to endorse or promote products derived from this software
192949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project *    without specific prior written permission.
202949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project *
212949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
222949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
232949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
242949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
252949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
262949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
272949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
282949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
292949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
302949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
312949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * SUCH DAMAGE.
322949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project */
332949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project
342949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#if defined(LIBC_SCCS) && !defined(lint)
352949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Projectstatic const char rcsid[] =
3653f17a9db278d33517d9888dd77848f554522a38JP Abgrall    "@(#) $Header: /tcpdump/master/tcpdump/missing/strdup.c,v 1.1 2001-01-20 07:26:08 guy Exp $ (LBL)";
372949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#endif /* LIBC_SCCS and not lint */
382949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project
392949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#include <stddef.h>
402949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#include <stdlib.h>
412949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#include <string.h>
422949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project
432949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#include "interface.h"
442949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project
452949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Projectchar *
462949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Projectstrdup(str)
472949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project	const char *str;
482949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project{
492949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project	size_t len;
502949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project	char *copy;
512949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project
522949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project	len = strlen(str) + 1;
532949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project	if ((copy = malloc(len)) == NULL)
542949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project		return (NULL);
552949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project	memcpy(copy, str, len);
562949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project	return (copy);
572949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project}
58