No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / texinfo / lib / strdup.c
blob1d79ea2528062d1f98a0eae23ee11fc14f94aa26
1 /* $NetBSD$ */
3 /* Copyright (C) 1991, 1996, 1997, 1998, 2002, 2003, 2004 Free Software
4 Foundation, Inc.
6 This file is part of the GNU C Library.
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 2, or (at your option)
11 any later version.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22 #ifdef HAVE_CONFIG_H
23 # include <config.h>
24 #endif
26 #ifndef _LIBC
27 /* Get specification. */
28 # include "strdup.h"
29 #endif
31 #include <stdlib.h>
32 #include <string.h>
34 #undef __strdup
35 #undef strdup
37 #ifndef weak_alias
38 # define __strdup strdup
39 #endif
41 /* Duplicate S, returning an identical malloc'd string. */
42 char *
43 __strdup (const char *s)
45 size_t len = strlen (s) + 1;
46 void *new = malloc (len);
48 if (new == NULL)
49 return NULL;
51 return (char *) memcpy (new, s, len);
53 #ifdef libc_hidden_def
54 libc_hidden_def (__strdup)
55 #endif
56 #ifdef weak_alias
57 weak_alias (__strdup, strdup)
58 #endif