summaryrefslogtreecommitdiff
path: root/src/renderer/tr_image_bmp.c
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2009-10-03 12:31:59 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:16:03 +0000
commit304d4258d3a49488f570b8ad71931faa7e5d40ba (patch)
treebf9ec15bd9154305ff9fab2943b3daf25024f8a5 /src/renderer/tr_image_bmp.c
parent6e90e4e7861f5cb354487d1fe0f1fd06c385308e (diff)
* Merge ioq3-r1498, by popular demand
Diffstat (limited to 'src/renderer/tr_image_bmp.c')
-rw-r--r--src/renderer/tr_image_bmp.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/renderer/tr_image_bmp.c b/src/renderer/tr_image_bmp.c
index 190b878f..0b78abb8 100644
--- a/src/renderer/tr_image_bmp.c
+++ b/src/renderer/tr_image_bmp.c
@@ -50,7 +50,10 @@ void R_LoadBMP( const char *name, byte **pic, int *width, int *height )
int row, column;
byte *buf_p;
byte *end;
- byte *buffer = NULL;
+ union {
+ byte *b;
+ void *v;
+ } buffer;
int length;
BMPHeader_t bmpHeader;
byte *bmpRGBA;
@@ -66,8 +69,8 @@ void R_LoadBMP( const char *name, byte **pic, int *width, int *height )
//
// load the file
//
- length = ri.FS_ReadFile( ( char * ) name, (void **)&buffer);
- if (!buffer || length < 0) {
+ length = ri.FS_ReadFile( ( char * ) name, &buffer.v);
+ if (!buffer.b || length < 0) {
return;
}
@@ -76,8 +79,8 @@ void R_LoadBMP( const char *name, byte **pic, int *width, int *height )
ri.Error( ERR_DROP, "LoadBMP: header too short (%s)\n", name );
}
- buf_p = buffer;
- end = buffer + length;
+ buf_p = buffer.b;
+ end = buffer.b + length;
bmpHeader.id[0] = *buf_p++;
bmpHeader.id[1] = *buf_p++;
@@ -119,12 +122,12 @@ void R_LoadBMP( const char *name, byte **pic, int *width, int *height )
buf_p += sizeof(bmpHeader.palette);
}
- if (buffer + bmpHeader.bitmapDataOffset > end)
+ if (buffer.b + bmpHeader.bitmapDataOffset > end)
{
ri.Error( ERR_DROP, "LoadBMP: invalid offset value in header (%s)\n", name );
}
- buf_p = buffer + bmpHeader.bitmapDataOffset;
+ buf_p = buffer.b + bmpHeader.bitmapDataOffset;
if ( bmpHeader.id[0] != 'B' && bmpHeader.id[1] != 'M' )
{
@@ -231,6 +234,6 @@ void R_LoadBMP( const char *name, byte **pic, int *width, int *height )
}
}
- ri.FS_FreeFile( buffer );
+ ri.FS_FreeFile( buffer.v );
}