summaryrefslogtreecommitdiffstats
path: root/usr.bin/patch/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/patch/util.c')
-rw-r--r--usr.bin/patch/util.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c
index 876eda36e42..4db53a42b5b 100644
--- a/usr.bin/patch/util.c
+++ b/usr.bin/patch/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.37 2014/11/22 15:49:28 tobias Exp $ */
+/* $OpenBSD: util.c,v 1.38 2014/12/13 10:31:07 tobias Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -192,6 +192,22 @@ savestr(const char *s)
}
/*
+ * Allocate a unique area for a string. Call fatal if out of memory.
+ */
+char *
+xstrdup(const char *s)
+{
+ char *rv;
+
+ if (!s)
+ s = "Oops";
+ rv = strdup(s);
+ if (rv == NULL)
+ fatal("out of memory\n");
+ return rv;
+}
+
+/*
* Vanilla terminal output (buffered).
*/
void