|
Packit |
549fdc |
/* Copyright (C) 1991, 1996-1998, 2002-2004, 2006-2007, 2009-2016 Free Software
|
|
Packit |
549fdc |
Foundation, Inc.
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
This file is part of the GNU C Library.
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
This program is free software; you can redistribute it and/or modify
|
|
Packit |
549fdc |
it under the terms of the GNU General Public License as published by
|
|
Packit |
549fdc |
the Free Software Foundation; either version 3, or (at your option)
|
|
Packit |
549fdc |
any later version.
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
This program is distributed in the hope that it will be useful,
|
|
Packit |
549fdc |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
549fdc |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
549fdc |
GNU General Public License for more details.
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
You should have received a copy of the GNU General Public License along
|
|
Packit |
549fdc |
with this program; if not, see <http://www.gnu.org/licenses/>. */
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
#ifndef _LIBC
|
|
Packit |
549fdc |
# include <config.h>
|
|
Packit |
549fdc |
#endif
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
/* Get specification. */
|
|
Packit |
549fdc |
#include <string.h>
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
#include <stdlib.h>
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
#undef __strdup
|
|
Packit |
549fdc |
#ifdef _LIBC
|
|
Packit |
549fdc |
# undef strdup
|
|
Packit |
549fdc |
#endif
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
#ifndef weak_alias
|
|
Packit |
549fdc |
# define __strdup strdup
|
|
Packit |
549fdc |
#endif
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
/* Duplicate S, returning an identical malloc'd string. */
|
|
Packit |
549fdc |
char *
|
|
Packit |
549fdc |
__strdup (const char *s)
|
|
Packit |
549fdc |
{
|
|
Packit |
549fdc |
size_t len = strlen (s) + 1;
|
|
Packit |
549fdc |
void *new = malloc (len);
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
if (new == NULL)
|
|
Packit |
549fdc |
return NULL;
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
return (char *) memcpy (new, s, len);
|
|
Packit |
549fdc |
}
|
|
Packit |
549fdc |
#ifdef libc_hidden_def
|
|
Packit |
549fdc |
libc_hidden_def (__strdup)
|
|
Packit |
549fdc |
#endif
|
|
Packit |
549fdc |
#ifdef weak_alias
|
|
Packit |
549fdc |
weak_alias (__strdup, strdup)
|
|
Packit |
549fdc |
#endif
|