Browse Source

Changed stb-image to use bbGC::malloc.

Mark Sibly 8 years ago
parent
commit
57a97b6622

+ 14 - 0
modules/stb-image/native/stb_image.c → modules/stb-image/native/stb_image.cpp

@@ -1,3 +1,17 @@
+#include <bbmonkey.h>
+
+#define STBI_MALLOC(sz) bbGC::malloc(sz)
+#define STBI_REALLOC(p,newsz) bbRealloc(p,newsz)
+#define STBI_REALLOC_SIZED(p,oldsz,newsz) bbRealloc(p,newsz)
+#define STBI_FREE(p) bbGC::free(p)
+
+void *bbRealloc( void *p,size_t newsz ){
+	void *newp=bbGC::malloc( newsz );
+	size_t oldsz=bbGC::mallocSize( p );
+	memcpy( newp,p,oldsz<newsz ? oldsz : newsz );
+	bbGC::free( p );
+	return newp;
+}
 
 #include "stb_image.h"
 

+ 1 - 0
modules/stb-image/native/stb_image.h

@@ -1,3 +1,4 @@
+
 /* stb_image - v2.14 - public domain image loader - http://nothings.org/stb_image.h
                                      no warranty implied; use at your own risk
 

+ 1 - 1
modules/stb-image/stb-image.monkey2

@@ -1,7 +1,7 @@
 
 Namespace stb.image
 
-#Import "native/stb_image.c"
+#Import "native/stb_image.cpp"
 #Import "native/stb_image.h"
 
 Extern