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