shithub: choc

Download patch

ref: 12cf8abde16bc7c47b78744a528a46b57be7adf5
parent: e334de61580e02c7fce892dd185b5c3fd7ff6e5d
author: Fabian Greffrath <fabian@greffrath.com>
date: Mon Aug 21 07:36:13 EDT 2017

i_system: Add an I_Realloc() function

--- a/src/i_system.c
+++ b/src/i_system.c
@@ -324,6 +324,28 @@
 }
 
 //
+// I_Realloc
+//
+
+void *I_Realloc(void *ptr, size_t size)
+{
+    void *new_ptr;
+
+    new_ptr = realloc(ptr, size);
+
+    if (size != 0 && new_ptr == NULL)
+    {
+        I_Error ("I_Realloc: failed on reallocation of %i bytes", size);
+    }
+    else
+    {
+        ptr = new_ptr;
+    }
+
+    return ptr;
+}
+
+//
 // Read Access Violation emulation.
 //
 // From PrBoom+, by entryway.
--- a/src/i_system.h
+++ b/src/i_system.h
@@ -56,6 +56,8 @@
 
 void I_Tactile (int on, int off, int total);
 
+void *I_Realloc(void *ptr, size_t size);
+
 boolean I_GetMemoryValue(unsigned int offset, void *value, int size);
 
 // Schedule a function to be called when the program exits.