- Fixed a HEAP error (Invalid Address specified to RtlFreeHeap) on Windows (MSVC compile) (src/data.c)

- Pointed out other locations where that error could occur (src/data.c, lib/ivis_common/pcx.c)
- Deprecated pie_ReloadTexPage, as it doesn't appear to be used (lib/ivis_opengl/tex.c)
- Made iSprite width and heigth unsigned (lib/ivis_common/pietypes.h)
- Added debugging for MSVC which doesn't understand the DB* redefines (lib/ivis_common/bitimage.c)
- Fixed deprecation for MSVC (lib/framework/macros.h

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@452 4a71c877-e1ca-e34f-864e-861f7616d084
master
Dennis Schridde 2006-07-03 19:43:12 +00:00
parent 8627f307cc
commit 1b1a695684
7 changed files with 30 additions and 12 deletions

6
TODO
View File

@ -12,10 +12,14 @@ Easy:
- Add a shadow toggle to src/clparse.c
- Make Warzone respond to the SDL_QUIT event so it can be closed with ^C, ALT+F4 or closing the window.
More difficult:
- Create one single place where platform dependend defines reside
- Create one single place where platform dependend defines reside.
- Create a "super header" which is included in every header before any other headers.
This is needed eg for debugging memleaks through malloc redefinitions (eg when using MSVCRT).
- [separation] Work out an engine part (lib/) and a game part (src/),
where no engine part depends on any game part

View File

@ -41,7 +41,7 @@
*/
#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2))
# define WZ_DEPRECATED __attribute__ ((__deprecated__))
#elif defined(_MSVC_VER) && (_MSC_VER >= 1300)
#elif defined(_MSC_VER) && (_MSC_VER >= 1300)
# define WZ_DEPRECATED __declspec(deprecated)
#else
# define WZ_DEPRECATED

View File

@ -84,20 +84,20 @@ IMAGEFILE *iV_LoadImageFile(UBYTE *FileData, UDWORD FileSize)
ImageFile = MALLOC(sizeof(IMAGEFILE));
if(ImageFile == NULL) {
DBERROR(("Out of memory"));
debug( LOG_ERROR, "Out of memory" );
return NULL;
}
ImageFile->TexturePages = MALLOC(sizeof(iSprite)*Header->NumTPages);
if(ImageFile->TexturePages == NULL) {
DBERROR(("Out of memory"));
debug( LOG_ERROR, "Out of memory" );
return NULL;
}
ImageFile->ImageDefs = MALLOC(sizeof(IMAGEDEF)*Header->NumImages);
if(ImageFile->ImageDefs == NULL) {
DBERROR(("Out of memory"));
debug( LOG_ERROR, "Out of memory" );
return NULL;
}
@ -113,7 +113,7 @@ IMAGEFILE *iV_LoadImageFile(UBYTE *FileData, UDWORD FileSize)
for(i=0; i<Header->NumImages; i++) {
ImageFile->ImageDefs[i] = *ImageDef;
if( (ImageDef->Width <= 0) || (ImageDef->Height <= 0) ) {
DBERROR(("Illegal image size"));
debug( LOG_ERROR, "Illegal image size" );
return NULL;
}
ImageDef++;

View File

@ -103,6 +103,7 @@ iBool pie_PNGLoadMem(int8 *pngimage, iSprite *s, iColour *pal)
s->width = w;
s->height = h;
// Freeing s->bmp before allocating new mem would give a HEAP error on Windows (Invalid Address specified to RtlFreeHeap( x, x )).
s->bmp = malloc(w*h*info_ptr->channels);
}

View File

@ -49,7 +49,7 @@ typedef uint8 iBitmap;
typedef struct {uint8 r, g, b;} iColour;
typedef int iBool;
typedef struct {int32 x, y;} iPoint;
typedef struct {int width, height; iBitmap *bmp;} iSprite;
typedef struct {unsigned int width, height; iBitmap *bmp;} iSprite;
typedef iColour iPalette[256];
typedef struct {uint8 r, g, b, p;} iRGB8;
typedef struct {uint16 r, g, b, p;} iRGB16;

View File

@ -178,10 +178,14 @@ int iV_GetTexture(char *filename)
return -1;
}
int pie_ReloadTexPage(STRING *filename, SBYTE *pBuffer)
// According to logfile not used, deprecating
WZ_DEPRECATED int pie_ReloadTexPage(STRING *filename, SBYTE *pBuffer)
{
int i = 0;
iSprite s;
iSprite s;
// Log call to check validity of deprecation
debug( LOG_NEVER, "pie_ReloadTexPage called" );
/* Have we already loaded this one then? */
while (stricmp(filename,_TEX_PAGE[i].name) != 0) {

View File

@ -866,7 +866,11 @@ void dataTERTILESRelease(void *pData)
iSprite *psSprite = (iSprite*) pData;
freeTileTextures();
dataISpriteRelease(psSprite);
if( psSprite->bmp )
{
free(psSprite->bmp);
psSprite->bmp = NULL;
}
bTilesPCXLoaded = FALSE;
}
@ -930,7 +934,12 @@ void dataHWTERTILESRelease(void *pData)
iSprite *psSprite = (iSprite*) pData;
freeTileTextures();
dataISpriteRelease(psSprite);
if( psSprite->bmp )
{
free(psSprite->bmp);
psSprite->bmp = NULL;
}
// We are not allowed to free psSprite also, this would give an error on Windows: HEAP[Warzone.exe]: Invalid Address specified to RtlFreeHeap( xxx, xxx )
bTilesPCXLoaded = FALSE;
pie_TexShutDown();
}
@ -1035,7 +1044,7 @@ BOOL bufferTexPageLoad(UBYTE *pBuffer, UDWORD size, void **ppData)
psPal = MALLOC(sizeof(iPalette));
if (!psPal) return FALSE;
psSprite = MALLOC(sizeof(iSprite));
psSprite = (iSprite*)MALLOC(sizeof(iSprite));
if (!psSprite)
{
return FALSE;