summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
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;