use g_malloc and g_free everywhere - causes Windows only crashes

This commit is contained in:
Timothee "TTimo" Besset 2013-09-14 15:46:37 -05:00
parent 03bf78c43f
commit 233c1f257e
2 changed files with 5 additions and 5 deletions

View file

@ -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 );
}
/*

View file

@ -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;