Fixes to Malloc() and Free() in mojoshader_opengl.c ... trunk
authorRyan C. Gordon <icculus@icculus.org>
Sun, 27 Apr 2008 05:04:38 -0400
branchtrunk
changeset 220 df5ea69833d5
parent 219 61167fc96790
child 221 328ac819b965
Fixes to Malloc() and Free() in mojoshader_opengl.c ...
mojoshader_opengl.c
--- a/mojoshader_opengl.c	Sun Apr 27 05:01:18 2008 -0400
+++ b/mojoshader_opengl.c	Sun Apr 27 05:04:38 2008 -0400
@@ -86,12 +86,16 @@
 
 static inline void *Malloc(const size_t len)
 {
-    return malloc_fn(len, malloc_data);
+    void *retval = malloc_fn(len, malloc_data);
+    if (retval == NULL)
+        set_error("out of memory");
+    return retval;
 } // Malloc
 
 static inline void Free(void *ptr)
 {
-    return free_fn(ptr, malloc_data);
+    if (ptr != NULL)
+        free_fn(ptr, malloc_data);
 } // Free