summaryrefslogtreecommitdiff
path: root/src/m_misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/m_misc.c')
-rw-r--r--src/m_misc.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/m_misc.c b/src/m_misc.c
index 8fa526dc..2e363412 100644
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -285,6 +285,26 @@ char *M_StrCaseStr(char *haystack, char *needle)
}
//
+// Safe version of strdup() that checks the string was successfully
+// allocated.
+//
+
+char *M_StringDuplicate(const char *orig)
+{
+ char *result;
+
+ result = strdup(orig);
+
+ if (result == NULL)
+ {
+ I_Error("Failed to duplicate string (length %i)\n",
+ strlen(orig));
+ }
+
+ return result;
+}
+
+//
// String replace function.
//