Mercurial > hg > octave-kai > gnulib-hg
annotate lib/strdup.c @ 17249:e542fd46ad6f
maint: update all copyright year number ranges
Run "make update-copyright". Compare to commit 1602f0a from last year.
Signed-off-by: Eric Blake <eblake@redhat.com>
author | Eric Blake <eblake@redhat.com> |
---|---|
date | Tue, 01 Jan 2013 00:50:58 +0000 |
parents | bb182ee4a09d |
children |
rev | line source |
---|---|
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16366
diff
changeset
|
1 /* Copyright (C) 1991, 1996-1998, 2002-2004, 2006-2007, 2009-2013 Free Software |
14079
97fc9a21a8fb
maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents:
12559
diff
changeset
|
2 Foundation, Inc. |
4691 | 3 |
3943
3e25885877b3
copy from libc/string (via ../config/srclist*).
Karl Berry <karl@freefriends.org>
parents:
2807
diff
changeset
|
4 This file is part of the GNU C Library. |
5 | 5 |
4020 | 6 This program is free software; you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 2, or (at your option) | |
9 any later version. | |
5 | 10 |
4020 | 11 This program is distributed in the hope that it will be useful, |
5 | 12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
4020 | 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 GNU General Public License for more details. | |
5 | 15 |
4020 | 16 You should have received a copy of the GNU General Public License along |
16366
bb182ee4a09d
maint: replace FSF snail-mail addresses with URLs
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
17 with this program; if not, see <http://www.gnu.org/licenses/>. */ |
647 | 18 |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
19 #ifndef _LIBC |
4704 | 20 # include <config.h> |
4962
6bec4bfbd56e
Include strdup.h. From Simon Josefsson.
Bruno Haible <bruno@clisp.org>
parents:
4704
diff
changeset
|
21 #endif |
6bec4bfbd56e
Include strdup.h. From Simon Josefsson.
Bruno Haible <bruno@clisp.org>
parents:
4704
diff
changeset
|
22 |
7944
a1d177cd9523
* doc/gnulib-tool.texi (Initial import): Update to match current
Paul Eggert <eggert@cs.ucla.edu>
parents:
7473
diff
changeset
|
23 /* Get specification. */ |
a1d177cd9523
* doc/gnulib-tool.texi (Initial import): Update to match current
Paul Eggert <eggert@cs.ucla.edu>
parents:
7473
diff
changeset
|
24 #include <string.h> |
a1d177cd9523
* doc/gnulib-tool.texi (Initial import): Update to match current
Paul Eggert <eggert@cs.ucla.edu>
parents:
7473
diff
changeset
|
25 |
4691 | 26 #include <stdlib.h> |
3943
3e25885877b3
copy from libc/string (via ../config/srclist*).
Karl Berry <karl@freefriends.org>
parents:
2807
diff
changeset
|
27 |
3e25885877b3
copy from libc/string (via ../config/srclist*).
Karl Berry <karl@freefriends.org>
parents:
2807
diff
changeset
|
28 #undef __strdup |
7473
44fe37f21d92
Make it possible to alias stpcpy and strdup.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
29 #ifdef _LIBC |
44fe37f21d92
Make it possible to alias stpcpy and strdup.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
30 # undef strdup |
44fe37f21d92
Make it possible to alias stpcpy and strdup.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
31 #endif |
3943
3e25885877b3
copy from libc/string (via ../config/srclist*).
Karl Berry <karl@freefriends.org>
parents:
2807
diff
changeset
|
32 |
3e25885877b3
copy from libc/string (via ../config/srclist*).
Karl Berry <karl@freefriends.org>
parents:
2807
diff
changeset
|
33 #ifndef weak_alias |
3e25885877b3
copy from libc/string (via ../config/srclist*).
Karl Berry <karl@freefriends.org>
parents:
2807
diff
changeset
|
34 # define __strdup strdup |
5 | 35 #endif |
36 | |
4039
7c15210f0e35
copy strdup.c from libc again.
Karl Berry <karl@freefriends.org>
parents:
4020
diff
changeset
|
37 /* Duplicate S, returning an identical malloc'd string. */ |
5 | 38 char * |
3943
3e25885877b3
copy from libc/string (via ../config/srclist*).
Karl Berry <karl@freefriends.org>
parents:
2807
diff
changeset
|
39 __strdup (const char *s) |
5 | 40 { |
3943
3e25885877b3
copy from libc/string (via ../config/srclist*).
Karl Berry <karl@freefriends.org>
parents:
2807
diff
changeset
|
41 size_t len = strlen (s) + 1; |
3e25885877b3
copy from libc/string (via ../config/srclist*).
Karl Berry <karl@freefriends.org>
parents:
2807
diff
changeset
|
42 void *new = malloc (len); |
3e25885877b3
copy from libc/string (via ../config/srclist*).
Karl Berry <karl@freefriends.org>
parents:
2807
diff
changeset
|
43 |
3e25885877b3
copy from libc/string (via ../config/srclist*).
Karl Berry <karl@freefriends.org>
parents:
2807
diff
changeset
|
44 if (new == NULL) |
3e25885877b3
copy from libc/string (via ../config/srclist*).
Karl Berry <karl@freefriends.org>
parents:
2807
diff
changeset
|
45 return NULL; |
5 | 46 |
3943
3e25885877b3
copy from libc/string (via ../config/srclist*).
Karl Berry <karl@freefriends.org>
parents:
2807
diff
changeset
|
47 return (char *) memcpy (new, s, len); |
5 | 48 } |
3943
3e25885877b3
copy from libc/string (via ../config/srclist*).
Karl Berry <karl@freefriends.org>
parents:
2807
diff
changeset
|
49 #ifdef libc_hidden_def |
3e25885877b3
copy from libc/string (via ../config/srclist*).
Karl Berry <karl@freefriends.org>
parents:
2807
diff
changeset
|
50 libc_hidden_def (__strdup) |
3e25885877b3
copy from libc/string (via ../config/srclist*).
Karl Berry <karl@freefriends.org>
parents:
2807
diff
changeset
|
51 #endif |
3e25885877b3
copy from libc/string (via ../config/srclist*).
Karl Berry <karl@freefriends.org>
parents:
2807
diff
changeset
|
52 #ifdef weak_alias |
3e25885877b3
copy from libc/string (via ../config/srclist*).
Karl Berry <karl@freefriends.org>
parents:
2807
diff
changeset
|
53 weak_alias (__strdup, strdup) |
3e25885877b3
copy from libc/string (via ../config/srclist*).
Karl Berry <karl@freefriends.org>
parents:
2807
diff
changeset
|
54 #endif |