annotate lib/xstrdup.c @ 5:41c9d08b09d7

Initial revision
author Jim Meyering <jim@meyering.net>
date Sat, 31 Oct 1992 20:42:48 +0000
parents
children 395da10fb137 89f4c1937ac7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
1 /* xstrdup.c -- copy a string with out of memory checking
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
2 Copyright (C) 1990 Free Software Foundation, Inc.
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
3
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
6 the Free Software Foundation; either version 2, or (at your option)
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
7 any later version.
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
8
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
12 GNU General Public License for more details.
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
13
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
15 along with this program; if not, write to the Free Software
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
17
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
18 #if defined(USG) || defined(STDC_HEADERS)
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
19 #include <string.h>
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
20 #else
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
21 #include <strings.h>
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
22 #endif
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
23 char *xmalloc ();
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
24
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
25 /* Return a newly allocated copy of STRING. */
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
26
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
27 char *
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
28 xstrdup (string)
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
29 char *string;
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
30 {
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
31 return strcpy (xmalloc (strlen (string) + 1), string);
41c9d08b09d7 Initial revision
Jim Meyering <jim@meyering.net>
parents:
diff changeset
32 }