From 233c1f257e48f67d63a4a07e4127a1120c8d1064 Mon Sep 17 00:00:00 2001 From: "Timothee \"TTimo\" Besset" Date: Sat, 14 Sep 2013 15:46:37 -0500 Subject: [PATCH] use g_malloc and g_free everywhere - causes Windows only crashes --- plugins/image/lbmlib.cpp | 6 +++--- plugins/vfspak/vfs.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/image/lbmlib.cpp b/plugins/image/lbmlib.cpp index 7ad13114..3ea123cb 100644 --- a/plugins/image/lbmlib.cpp +++ b/plugins/image/lbmlib.cpp @@ -317,7 +317,7 @@ static void LoadPCX( const char *filename, byte **pic, byte **palette, int *widt } if ( palette ) { - *palette = (byte *)malloc( 768 ); + *palette = (byte *)g_malloc( 768 ); memcpy( *palette, (byte *)pcx + len - 768, 768 ); } @@ -332,7 +332,7 @@ static void LoadPCX( const char *filename, byte **pic, byte **palette, int *widt return; } - out = (byte *)malloc( ( pcx->ymax + 1 ) * ( pcx->xmax + 1 ) ); + out = (byte *)g_malloc( ( pcx->ymax + 1 ) * ( pcx->xmax + 1 ) ); if ( !out ) { Error( "LoadPCX: couldn't allocate" ); } @@ -369,7 +369,7 @@ static void LoadPCX( const char *filename, byte **pic, byte **palette, int *widt if ( raw - (byte *) pcx > len ) { Error( "PCX file %s was malformed", filename ); } - free( pcx ); + g_free( pcx ); } /* diff --git a/plugins/vfspak/vfs.cpp b/plugins/vfspak/vfs.cpp index 47f9b829..1c72c79b 100644 --- a/plugins/vfspak/vfs.cpp +++ b/plugins/vfspak/vfs.cpp @@ -525,7 +525,7 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){ len = ftell( f ); rewind( f ); - *bufferptr = malloc( len + 1 ); + *bufferptr = g_malloc( len + 1 ); if ( *bufferptr == NULL ) { return -1; } @@ -554,7 +554,7 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){ if ( count == index ) { fseek( file->pak, file->entry.offset, SEEK_SET ); - *bufferptr = malloc( file->entry.size + 1 ); + *bufferptr = g_malloc( file->entry.size + 1 ); // we need to end the buffer with a 0 ( (char*) ( *bufferptr ) )[file->entry.size] = 0;