foxygit / doom Log in
commit 12cf8abde16bc7c47b78744a528a46b57be7adf5
Author:     Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Mon Aug 21 11:36:13 2017 +0200
Commit:     Fabian Greffrath <fabian@greffrath.com>
CommitDate: Mon Aug 21 11:36:13 2017 +0200

    i_system: Add an I_Realloc() function
---
 src/i_system.c | 22 ++++++++++++++++++++++
 src/i_system.h |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/src/i_system.c b/src/i_system.c
index 28fa7656..187c2c46 100644
--- a/src/i_system.c
+++ b/src/i_system.c
@@ -323,6 +323,28 @@ void I_Error (char *error, ...)
     exit(-1);
 }

+//
+// 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.
 //
diff --git a/src/i_system.h b/src/i_system.h
index b65daff0..049774a7 100644
--- a/src/i_system.h
+++ b/src/i_system.h
@@ -56,6 +56,8 @@ void I_Error (char *error, ...);

 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.