|
Packit |
67cb25 |
/* strdup.c -- return a newly allocated copy of a string
|
|
Packit |
67cb25 |
Copyright (C) 1990 Free Software Foundation, Inc.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This program is free software; you can redistribute it and/or modify
|
|
Packit |
67cb25 |
it under the terms of the GNU General Public License as published by
|
|
Packit |
67cb25 |
the Free Software Foundation; either version 3, or (at your option)
|
|
Packit |
67cb25 |
any later version.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This program is distributed in the hope that it will be useful,
|
|
Packit |
67cb25 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
67cb25 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
67cb25 |
GNU General Public License for more details.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
You should have received a copy of the GNU General Public License
|
|
Packit |
67cb25 |
along with this program; if not, write to the Free Software
|
|
Packit |
67cb25 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
#if HAVE_CONFIG_H
|
|
Packit |
67cb25 |
#include <config.h>
|
|
Packit |
67cb25 |
#endif
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
#ifdef STDC_HEADERS
|
|
Packit |
67cb25 |
#include <string.h>
|
|
Packit |
67cb25 |
#include <stdlib.h>
|
|
Packit |
67cb25 |
#else
|
|
Packit |
67cb25 |
char *malloc ();
|
|
Packit |
67cb25 |
char *strcpy ();
|
|
Packit |
67cb25 |
#endif
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
/* Return a newly allocated copy of STR,
|
|
Packit |
67cb25 |
or 0 if out of memory. */
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
char *
|
|
Packit |
67cb25 |
strdup (str)
|
|
Packit |
67cb25 |
const char *str;
|
|
Packit |
67cb25 |
{
|
|
Packit |
67cb25 |
char *newstr;
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
newstr = (char *) malloc (strlen (str) + 1);
|
|
Packit |
67cb25 |
if (newstr)
|
|
Packit |
67cb25 |
strcpy (newstr, str);
|
|
Packit |
67cb25 |
return newstr;
|
|
Packit |
67cb25 |
}
|