summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>1999-03-05 07:13:12 +0000
committerPaul Smith <psmith@gnu.org>1999-03-05 07:13:12 +0000
commita6a9ebb54f67cb13a07dd3b815c258ae8c35b3ac (patch)
treecb34f435ff0d7400690485733f42e2335d4d163f /misc.c
parent9e6ba6a148aa6e4a6aed496d91bac44323325445 (diff)
downloadgunmake-a6a9ebb54f67cb13a07dd3b815c258ae8c35b3ac.tar.gz
* Define and use xstrdup() instead of strdup().
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/misc.c b/misc.c
index 87694e2..505b186 100644
--- a/misc.c
+++ b/misc.c
@@ -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;