diff options
author | Paul Smith <psmith@gnu.org> | 1999-03-05 07:13:12 +0000 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 1999-03-05 07:13:12 +0000 |
commit | a6a9ebb54f67cb13a07dd3b815c258ae8c35b3ac (patch) | |
tree | cb34f435ff0d7400690485733f42e2335d4d163f /misc.c | |
parent | 9e6ba6a148aa6e4a6aed496d91bac44323325445 (diff) | |
download | gunmake-a6a9ebb54f67cb13a07dd3b815c258ae8c35b3ac.tar.gz |
* Define and use xstrdup() instead of strdup().
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -378,6 +378,29 @@ xrealloc (ptr, size) return result; } + +const char * +xstrdup (ptr) + const char *ptr; +{ + char *result; + +#ifdef HAVE_STRDUP + result = strdup (ptr); +#else + result = (char *) malloc (strlen (ptr) + 1); +#endif + + if (result == 0) + fatal (NILF, "virtual memory exhausted"); + +#ifdef HAVE_STRDUP + return result; +#else + return strcpy(result, ptr); +#endif +} + char * savestring (str, length) char *str; |