added function to allocate and copy memory
[rocksndiamonds.git] / src / libgame / misc.c
index 5fd8e3c20966170bb3a71d3e60ad11274271a022..c96fa177de8ad5ebfb50cb7daa3242db7654ebe7 100644 (file)
@@ -1084,6 +1084,24 @@ char *getBasePath(char *filename)
 }
 
 
+// ----------------------------------------------------------------------------
+// various string functions
+// ----------------------------------------------------------------------------
+
+void *getMemCopy(const void *m, size_t size)
+{
+  void *m_copy;
+
+  if (m == NULL)
+    return NULL;
+
+  m_copy = checked_malloc(size);
+  memcpy(m_copy, m, size);
+
+  return m_copy;
+}
+
+
 // ----------------------------------------------------------------------------
 // various string functions
 // ----------------------------------------------------------------------------