]> git.cworth.org Git - tar/blob - gnu/strdup.c
upstream: Fix extraction of device nodes.
[tar] / gnu / strdup.c
1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Copyright (C) 1991, 1996, 1997, 1998, 2002, 2003, 2004, 2006, 2007, 2009,
4    2010 Free Software Foundation, Inc.
5
6    This file is part of the GNU C Library.
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3, or (at your option)
11    any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License along
19    with this program; if not, write to the Free Software Foundation,
20    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
21
22 #ifndef _LIBC
23 # include <config.h>
24 #endif
25
26 /* Get specification.  */
27 #include <string.h>
28
29 #include <stdlib.h>
30
31 #undef __strdup
32 #ifdef _LIBC
33 # undef strdup
34 #endif
35
36 #ifndef weak_alias
37 # define __strdup strdup
38 #endif
39
40 /* Duplicate S, returning an identical malloc'd string.  */
41 char *
42 __strdup (const char *s)
43 {
44   size_t len = strlen (s) + 1;
45   void *new = malloc (len);
46
47   if (new == NULL)
48     return NULL;
49
50   return (char *) memcpy (new, s, len);
51 }
52 #ifdef libc_hidden_def
53 libc_hidden_def (__strdup)
54 #endif
55 #ifdef weak_alias
56 weak_alias (__strdup, strdup)
57 #endif