FREE->free, MALLOC->malloc (sed+review)

This patch will create crashes where the code expects FREE to set the pointer to NULL! (Those problems should be fixed anyway.)
The only occassion where I saw this is when quiting a game, so it is not too much of an issue.


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1459 4a71c877-e1ca-e34f-864e-861f7616d084
master
Dennis Schridde 2007-04-15 10:43:05 +00:00
parent 2707ce0fd6
commit ce16856887
72 changed files with 698 additions and 706 deletions

View File

@ -223,7 +223,7 @@ static BOOL registry_load( const char *filename )
registry_set_key(key, buffer + l);
}
}
FREE(bufstart);
free(bufstart);
return TRUE;
}

View File

@ -438,7 +438,7 @@ static BOOL loadFile2(const char *pFileName, char **ppFileData, UDWORD *pFileSiz
if (AllocateMem == TRUE) {
// Allocate a buffer to store the data and a terminating zero
*ppFileData = (char*)MALLOC(filesize + 1);
*ppFileData = (char*)malloc(filesize + 1);
if (*ppFileData == NULL) {
debug(LOG_ERROR, "loadFile2: Out of memory loading %s", pFileName);
assert(FALSE);
@ -456,14 +456,14 @@ static BOOL loadFile2(const char *pFileName, char **ppFileData, UDWORD *pFileSiz
/* Load the file data */
length_read = PHYSFS_read(pfile, *ppFileData, 1, filesize);
if (length_read != filesize) {
FREE( *ppFileData );
free( *ppFileData );
debug(LOG_ERROR, "loadFile2: Reading %s short: %s",
pFileName, PHYSFS_getLastError());
assert(FALSE);
return FALSE;
}
if (!PHYSFS_close(pfile)) {
FREE( *ppFileData );
free( *ppFileData );
debug(LOG_ERROR, "loadFile2: Error closing %s: %s", pFileName,
PHYSFS_getLastError());
assert(FALSE);

View File

@ -130,7 +130,7 @@ BOOL resLoad(const char *pResFile, SDWORD blockID,
return FALSE;
}
FREE(pBuffer);
free(pBuffer);
return TRUE;
}
@ -151,7 +151,7 @@ static RES_TYPE* resAlloc(const char *pType)
#endif
// Allocate the memory
psT = (RES_TYPE *)MALLOC(sizeof(RES_TYPE));
psT = (RES_TYPE *)malloc(sizeof(RES_TYPE));
if (!psT)
{
debug( LOG_ERROR, "resAlloc: Out of memory" );
@ -346,7 +346,7 @@ static void FreeResourceFile(RESOURCEFILE *OldResource)
switch (OldResource->type)
{
case RESFILETYPE_LOADED:
FREE(OldResource->pBuffer);
free(OldResource->pBuffer);
break;
default:
debug(LOG_WARNING, "resource not freed");
@ -692,11 +692,11 @@ void resReleaseAll(void)
ASSERT( FALSE,"resReleaseAll: NULL release function" );
}
psNRes = psRes->psNext;
FREE(psRes);
free(psRes);
}
psNT = psT->psNext;
FREE(psT);
free(psT);
}
psResTypes = NULL;
@ -731,7 +731,7 @@ void resReleaseBlockData(SDWORD blockID)
}
psNRes = psRes->psNext;
FREE(psRes);
free(psRes);
if (psPRes == NULL)
{
@ -774,7 +774,7 @@ void resReleaseAllData(void)
}
psNRes = psRes->psNext;
FREE(psRes);
free(psRes);
}
psT->psRes = NULL;
psNT = psT->psNext;

View File

@ -60,7 +60,7 @@ void heapSetCallPos(const char *pFileName, SDWORD lineNumber)
cPos = lineNumber;
#if COPY_FILE_STRING
pCFile = (char *)MALLOC(strlen(pFileName) + 1);
pCFile = (char *)malloc(strlen(pFileName) + 1);
if (!pCFile)
{
return;
@ -151,7 +151,7 @@ BOOL heapCreate(OBJ_HEAP **ppsHeap, UDWORD size, UDWORD init, UDWORD ext)
#endif
/* Allocate the heap object and its memory */
*ppsHeap = (OBJ_HEAP *)MALLOC(sizeof(OBJ_HEAP));
*ppsHeap = (OBJ_HEAP *)malloc(sizeof(OBJ_HEAP));
if (*ppsHeap == NULL)
{
debug( LOG_ERROR, "heapCreate: Out of memory" );
@ -159,7 +159,7 @@ BOOL heapCreate(OBJ_HEAP **ppsHeap, UDWORD size, UDWORD init, UDWORD ext)
return FALSE;
}
// memset(*ppsHeap,0,sizeof(OBJ_HEAP)); //setting everything to 0 first (debug test)-Q
(*ppsHeap)->pMemory = (UBYTE *)MALLOC(size * init);
(*ppsHeap)->pMemory = (UBYTE *)malloc(size * init);
/*
if ((*ppsHeap)->pMemory == NULL)
@ -265,7 +265,7 @@ BOOL heapAlloc(OBJ_HEAP *psHeap, void **ppObject)
{
// heap doesn't expand
#if DEBUG_HEAP && COPY_FILE_STRING
FREE(pCFile);
free(pCFile);
#endif
return FALSE;
}
@ -274,19 +274,19 @@ BOOL heapAlloc(OBJ_HEAP *psHeap, void **ppObject)
debug(LOG_MEMORY, "heapAlloc: Heap %s, line %d extended. Max use: %d\n", psHeap->pFile, psHeap->line, psHeap->maxUsage);
#endif
psNew = (HEAP_EXTENSION *)MALLOC(sizeof(HEAP_EXTENSION));
psNew = (HEAP_EXTENSION *)malloc(sizeof(HEAP_EXTENSION));
if (psNew == NULL)
{
/* Out of memory */
return FALSE;
}
psNew->pMemory = (UBYTE *)MALLOC(psHeap->objSize * psHeap->extAlloc);
psNew->pMemory = (UBYTE *)malloc(psHeap->objSize * psHeap->extAlloc);
if (psNew->pMemory == NULL)
{
/* Out of memory */
FREE(psNew);
free(psNew);
return FALSE;
}
@ -387,7 +387,7 @@ BOOL heapFree(OBJ_HEAP *psHeap, void *pObject)
#if COPY_FILE_STRING
if (psHdr->pFile)
{
FREE(psHdr->pFile);
free(psHdr->pFile);
}
#endif
@ -483,7 +483,7 @@ void heapDestroy(OBJ_HEAP *psHeap)
#if COPY_FILE_STRING
if (psCurrHdr->pFile)
{
FREE(psCurrHdr->pFile);
free(psCurrHdr->pFile);
}
#endif
}
@ -510,7 +510,7 @@ void heapDestroy(OBJ_HEAP *psHeap)
#if COPY_FILE_STRING
if (psHeap->pFile)
{
FREE(psHeap->pFile);
free(psHeap->pFile);
}
#endif
@ -530,11 +530,11 @@ void heapDestroy(OBJ_HEAP *psHeap)
for(psExt = psHeap->psExt; psExt != NULL; psExt = psNext)
{
psNext = psExt->psNext;
FREE(psExt->pMemory);
FREE(psExt);
free(psExt->pMemory);
free(psExt);
}
FREE(psHeap->pMemory);
FREE(psHeap);
free(psHeap->pMemory);
free(psHeap);
}

View File

@ -24,9 +24,4 @@
#ifndef _mem_h
#define _mem_h
#include <stdlib.h>
#define MALLOC(size) malloc(size)
#define FREE(ptr) do { free(ptr); ptr = NULL; } while(0)
#endif

View File

@ -48,7 +48,7 @@ STR_RES *psCurrRes;
/* Allocate a string block */
static BOOL strresAllocBlock(STR_BLOCK **ppsBlock, UDWORD size)
{
*ppsBlock = (STR_BLOCK*)MALLOC(sizeof(STR_BLOCK));
*ppsBlock = (STR_BLOCK*)malloc(sizeof(STR_BLOCK));
if (!*ppsBlock)
{
debug( LOG_ERROR, "strresAllocBlock: Out of memory - 1" );
@ -56,18 +56,18 @@ static BOOL strresAllocBlock(STR_BLOCK **ppsBlock, UDWORD size)
return FALSE;
}
(*ppsBlock)->apStrings = (char**)MALLOC(sizeof(char *) * size);
(*ppsBlock)->apStrings = (char**)malloc(sizeof(char *) * size);
if (!(*ppsBlock)->apStrings)
{
debug( LOG_ERROR, "strresAllocBlock: Out of memory - 2" );
abort();
FREE(*ppsBlock);
free(*ppsBlock);
return FALSE;
}
memset((*ppsBlock)->apStrings, 0, sizeof(char *) * size);
#ifdef DEBUG
(*ppsBlock)->aUsage = (UDWORD*)MALLOC(sizeof(UDWORD) * size);
(*ppsBlock)->aUsage = (UDWORD*)malloc(sizeof(UDWORD) * size);
memset((*ppsBlock)->aUsage, 0, sizeof(UDWORD) * size);
#endif
@ -80,7 +80,7 @@ BOOL strresCreate(STR_RES **ppsRes, UDWORD init, UDWORD ext)
{
STR_RES *psRes;
psRes = (STR_RES*)MALLOC(sizeof(STR_RES));
psRes = (STR_RES*)malloc(sizeof(STR_RES));
if (!psRes)
{
debug( LOG_ERROR, "strresCreate: Out of memory" );
@ -95,14 +95,14 @@ BOOL strresCreate(STR_RES **ppsRes, UDWORD init, UDWORD ext)
{
debug( LOG_ERROR, "strresCreate: Out of memory" );
abort();
FREE(psRes);
free(psRes);
return FALSE;
}
if (!strresAllocBlock(&psRes->psStrings, init))
{
TREAP_DESTROY(psRes->psIDTreap);
FREE(psRes);
free(psRes);
return FALSE;
}
psRes->psStrings->psNext = NULL;
@ -131,8 +131,8 @@ void strresReleaseIDStrings(STR_RES *psRes)
TREAP_DEL(psRes->psIDTreap, (void*)psID->pIDStr);
if (psID->id & ID_ALLOC)
{
FREE(psID->pIDStr);
FREE(psID);
free(psID->pIDStr);
free(psID);
}
}
}
@ -164,7 +164,7 @@ void strresDestroy(STR_RES *psRes)
#endif
if (psBlock->apStrings[i - psBlock->idStart])
{
FREE(psBlock->apStrings[i - psBlock->idStart]);
free(psBlock->apStrings[i - psBlock->idStart]);
}
#ifdef DEBUG
else if (i < psRes->nextID)
@ -174,16 +174,16 @@ void strresDestroy(STR_RES *psRes)
#endif
}
psNext = psBlock->psNext;
FREE(psBlock->apStrings);
free(psBlock->apStrings);
#ifdef DEBUG
FREE(psBlock->aUsage);
free(psBlock->aUsage);
#endif
FREE(psBlock);
free(psBlock);
}
// Release the treap and free the final memory
TREAP_DESTROY(psRes->psIDTreap);
FREE(psRes);
free(psRes);
}
@ -280,19 +280,19 @@ BOOL strresStoreString(STR_RES *psRes, char *pID, char *pString)
if (!psID)
{
// No ID yet so generate a new one
psID = (STR_ID*)MALLOC(sizeof(STR_ID));
psID = (STR_ID*)malloc(sizeof(STR_ID));
if (!psID)
{
debug( LOG_ERROR, "strresStoreString: Out of memory" );
abort();
return FALSE;
}
psID->pIDStr = (char*)MALLOC(sizeof(char) * (stringLen(pID) + 1));
psID->pIDStr = (char*)malloc(sizeof(char) * (stringLen(pID) + 1));
if (!psID->pIDStr)
{
debug( LOG_ERROR, "strresStoreString: Out of memory" );
abort();
FREE(psID);
free(psID);
return FALSE;
}
stringCpy(psID->pIDStr, pID);
@ -335,7 +335,7 @@ BOOL strresStoreString(STR_RES *psRes, char *pID, char *pString)
}
// Allocate a copy of the string
pNew = (char*)MALLOC(sizeof(char) * (stringLen(pString) + 1));
pNew = (char*)malloc(sizeof(char) * (stringLen(pString) + 1));
if (!pNew)
{
debug( LOG_ERROR, "strresStoreString: Out of memory" );

View File

@ -45,7 +45,7 @@ void treapSetCallPos(const char *pFileName, SDWORD lineNumber)
{
cLine = lineNumber;
pCFile = (char *)MALLOC(strlen(pFileName) + 1);
pCFile = (char *)malloc(strlen(pFileName) + 1);
if (pCFile)
{
strcpy(pCFile, pFileName);
@ -87,7 +87,7 @@ SDWORD treapStringCmp(void *key1, void *key2)
BOOL treapCreate(TREAP **ppsTreap, TREAP_CMP cmp, UDWORD init, UDWORD ext)
{
*ppsTreap = (TREAP*)MALLOC(sizeof(TREAP));
*ppsTreap = (TREAP*)malloc(sizeof(TREAP));
if (!(*ppsTreap))
{
debug( LOG_ERROR, "treapCreate: Out of memory" );
@ -99,7 +99,7 @@ BOOL treapCreate(TREAP **ppsTreap, TREAP_CMP cmp, UDWORD init, UDWORD ext)
{
debug( LOG_ERROR, "treapCreate: Out of memory" );
abort();
FREE(*ppsTreap);
free(*ppsTreap);
return FALSE;
}
@ -295,7 +295,7 @@ BOOL treapDel(TREAP *psTreap, void *key)
// Release the node
#ifdef DEBUG_TREAP
FREE(psDel->pFile);
free(psDel->pFile);
#endif
HEAP_FREE(psTreap->psNodes, psDel);
@ -386,12 +386,12 @@ void treapDestroy(TREAP *psTreap)
debug( LOG_NEVER, "treapDestroy: %s, line %d : nodes still in the tree\n", psTreap->pFile, psTreap->line );
treapReportRec(psTreap->psRoot);
}
FREE(psTreap->pFile);
free(psTreap->pFile);
#endif
treapDestroyRec(psTreap->psRoot, psTreap->psNodes);
HEAP_DESTROY(psTreap->psNodes);
FREE(psTreap);
free(psTreap);
}
/* Recursively display the treap structure */

View File

@ -66,29 +66,29 @@ BOOL trigInitialise(void)
// Allocate the tables
aSin=(FRACT*)MALLOC(sizeof(FRACT) * TRIG_DEGREES);
aSin=(FRACT*)malloc(sizeof(FRACT) * TRIG_DEGREES);
if (!aSin)
{
return FALSE;
}
aCos=(FRACT*)MALLOC(sizeof(FRACT) * TRIG_DEGREES);
aCos=(FRACT*)malloc(sizeof(FRACT) * TRIG_DEGREES);
if (!aCos)
{
return FALSE;
}
aInvSin=(FRACT*)MALLOC(sizeof(FRACT) * TRIG_ACCURACY);
aInvSin=(FRACT*)malloc(sizeof(FRACT) * TRIG_ACCURACY);
if (!aInvSin)
{
return FALSE;
}
aInvCos=(FRACT*)MALLOC(sizeof(FRACT) * TRIG_ACCURACY);
aInvCos=(FRACT*)malloc(sizeof(FRACT) * TRIG_ACCURACY);
if (!aInvCos)
{
return FALSE;
}
aSqrt=(FRACT*)MALLOC(sizeof(FRACT) * SQRT_ACCURACY);
aSqrt=(FRACT*)malloc(sizeof(FRACT) * SQRT_ACCURACY);
if (!aSqrt)
{
return FALSE;
@ -127,11 +127,11 @@ BOOL trigInitialise(void)
void trigShutDown(void)
{
FREE(aSin);
FREE(aCos);
FREE(aInvSin);
FREE(aInvCos);
FREE(aSqrt);
free(aSin);
free(aCos);
free(aInvSin);
free(aInvCos);
free(aSqrt);
}

View File

@ -91,17 +91,17 @@ anim_ReleaseAnim( BASEANIM *psAnim )
LIST_REMOVE(g_animGlobals.psAnimList, psAnim, BASEANIM);
/* free anim scripts */
FREE( psAnim->psStates );
free( psAnim->psStates );
/* free anim shape */
if ( psAnim->animType == ANIM_3D_FRAMES ||
psAnim->animType == ANIM_3D_TRANS )
{
psAnim3D = (ANIM3D *) psAnim;
FREE( psAnim3D->apFrame );
free( psAnim3D->apFrame );
}
FREE(psAnim);
free(psAnim);
}
/***************************************************************************/
@ -142,7 +142,7 @@ anim_InitBaseMembers( BASEANIM * psAnim, UWORD uwStates, UWORD uwFrameRate,
psAnim->uwAnimTime = (UWORD) (uwStates*1000 / psAnim->uwFrameRate);
/* allocate frames */
psAnim->psStates = (ANIM_STATE*)MALLOC( uwObj*psAnim->uwStates*sizeof(ANIM_STATE) );
psAnim->psStates = (ANIM_STATE*)malloc( uwObj*psAnim->uwStates*sizeof(ANIM_STATE) );
}
/***************************************************************************/
@ -156,7 +156,7 @@ anim_Create3D( char szPieFileName[], UWORD uwStates,
UWORD uwFrames, i;
/* allocate anim */
if ( (psAnim3D = (ANIM3D*)MALLOC(sizeof(ANIM3D))) == NULL )
if ( (psAnim3D = (ANIM3D*)malloc(sizeof(ANIM3D))) == NULL )
{
return FALSE;
}
@ -190,7 +190,7 @@ anim_Create3D( char szPieFileName[], UWORD uwStates,
}
/* get pointers to individual frames */
psAnim3D->apFrame = (iIMDShape**)MALLOC( uwFrames*sizeof(iIMDShape *) );
psAnim3D->apFrame = (iIMDShape**)malloc( uwFrames*sizeof(iIMDShape *) );
psFrames = psAnim3D->psFrames;
for ( i=0; i<uwFrames; i++ )
{

View File

@ -96,9 +96,9 @@ hashTable_Create( HASHTABLE **ppsTable, UDWORD udwTableSize,
/* allocate and init table */
(*ppsTable) = (HASHTABLE*)MALLOC( sizeof(HASHTABLE) );
(*ppsTable) = (HASHTABLE*)malloc( sizeof(HASHTABLE) );
udwSize = udwTableSize * sizeof(HASHNODE *);
(*ppsTable)->ppsNode = (HASHNODE**)MALLOC( udwSize );
(*ppsTable)->ppsNode = (HASHNODE**)malloc( udwSize );
memset( (*ppsTable)->ppsNode, 0, udwSize );
/* allocate heaps */
@ -149,8 +149,8 @@ hashTable_Destroy( HASHTABLE *psTable )
HEAP_DESTROY( psTable->psElementHeap );
/* free table */
FREE( psTable->ppsNode );
FREE( psTable );
free( psTable->ppsNode );
free( psTable );
}
/***************************************************************************/

View File

@ -84,20 +84,20 @@ IMAGEFILE *iV_LoadImageFile(char *FileData, WZ_DECL_UNUSED UDWORD FileSize)
endian_uword(&Header->BitDepth);
endian_uword(&Header->NumTPages);
ImageFile = (IMAGEFILE*)MALLOC(sizeof(IMAGEFILE));
ImageFile = (IMAGEFILE*)malloc(sizeof(IMAGEFILE));
if(ImageFile == NULL) {
debug( LOG_ERROR, "Out of memory" );
return NULL;
}
ImageFile->TexturePages = (iTexture*)MALLOC(sizeof(iTexture)*Header->NumTPages);
ImageFile->TexturePages = (iTexture*)malloc(sizeof(iTexture)*Header->NumTPages);
if(ImageFile->TexturePages == NULL) {
debug( LOG_ERROR, "Out of memory" );
return NULL;
}
ImageFile->ImageDefs = (IMAGEDEF*)MALLOC(sizeof(IMAGEDEF)*Header->NumImages);
ImageFile->ImageDefs = (IMAGEDEF*)malloc(sizeof(IMAGEDEF)*Header->NumImages);
if(ImageFile->ImageDefs == NULL) {
debug( LOG_ERROR, "Out of memory" );
return NULL;
@ -142,12 +142,12 @@ void iV_FreeImageFile(IMAGEFILE *ImageFile)
{
// for(i=0; i<ImageFile->Header.NumTPages; i++) {
// FREE(ImageFile->TexturePages[i].bmp);
// free(ImageFile->TexturePages[i].bmp);
// }
FREE(ImageFile->TexturePages);
FREE(ImageFile->ImageDefs);
FREE(ImageFile);
free(ImageFile->TexturePages);
free(ImageFile->ImageDefs);
free(ImageFile);
}

View File

@ -452,32 +452,32 @@ void iV_IMDRelease(iIMDShape *s)
if (s) {
if (s->flags & iV_IMD_BINARY) {
FREE(s);
free(s);
return;
}
if (s->points) {
FREE(s->points);
free(s->points);
}
if (s->connectors) {
FREE(s->connectors);
free(s->connectors);
}
if (s->BSPNode) {
FREE(s->BSPNode); // I used MALLOC() so i'm going to use FREE()
free(s->BSPNode); // I used malloc() so i'm going to use FREE()
}
if (s->polys) {
for (i = 0; i < s->npolys; i++) {
if (s->polys[i].pindex) {
FREE(s->polys[i].pindex);
free(s->polys[i].pindex);
}
if (s->polys[i].pTexAnim) {
FREE(s->polys[i].pTexAnim);
free(s->polys[i].pTexAnim);
}
if (s->polys[i].vrt) {
FREE(s->polys[i].vrt);
free(s->polys[i].vrt);
}
}
FREE(s->polys);
free(s->polys);
}
if (s->shadowEdgeList)
{
@ -486,7 +486,7 @@ void iV_IMDRelease(iIMDShape *s)
}
iV_DEBUG0("imd[IMDRelease] = release successful\n");
d = s->next;
FREE(s);
free(s);
iV_IMDRelease(d);
}
}

View File

@ -277,7 +277,7 @@ static BOOL _imd_load_polys( char **ppFileData, iIMDShape *s )
s->numFrames = 0;
s->animInterval = 0;
s->polys = (iIMDPoly *) MALLOC(sizeof(iIMDPoly) * s->npolys);
s->polys = (iIMDPoly *) malloc(sizeof(iIMDPoly) * s->npolys);
if (s->polys) {
poly = s->polys;
@ -300,9 +300,9 @@ static BOOL _imd_load_polys( char **ppFileData, iIMDShape *s )
IMDVertexcount+= poly->npnts;
poly->pindex = (VERTEXID *) MALLOC(sizeof(VERTEXID) * poly->npnts);
poly->pindex = (VERTEXID *) malloc(sizeof(VERTEXID) * poly->npnts);
if ((poly->vrt = (iVertex *) MALLOC(sizeof(iVertex) * poly->npnts)) == NULL) {
if ((poly->vrt = (iVertex *) malloc(sizeof(iVertex) * poly->npnts)) == NULL) {
iV_Error(0xff,"(_load_polys) [poly %d] memory alloc fail (vertex struct)",i);
return FALSE;
}
@ -347,7 +347,7 @@ static BOOL _imd_load_polys( char **ppFileData, iIMDShape *s )
if (poly->flags & iV_IMD_TEXANIM) {
IMDTexAnims++;
if ((poly->pTexAnim = (iTexAnim *)MALLOC(sizeof(iTexAnim))) == NULL) {
if ((poly->pTexAnim = (iTexAnim *)malloc(sizeof(iTexAnim))) == NULL) {
iV_Error(0xff,"(_load_polys) [poly %d] memory alloc fail (iTexAnim struct)",i);
return FALSE;
}
@ -432,7 +432,7 @@ static BOOL _imd_load_bsp( char **ppFileData, iIMDShape *s, UWORD BSPNodeCount )
}
// Build table of nodes - we sort out the links later
NodeList = (BSPTREENODE*)MALLOC((sizeof(BSPTREENODE))*BSPNodeCount); // Allocate the entire node tree
NodeList = (BSPTREENODE*)malloc((sizeof(BSPTREENODE))*BSPNodeCount); // Allocate the entire node tree
memset(NodeList,0,(sizeof(BSPTREENODE))*BSPNodeCount); // Zero it out ... we need to make all pointers NULL
@ -654,7 +654,7 @@ static BOOL _imd_load_points( char **ppFileData, iIMDShape *s )
IMDPoints+=s->npoints;
s->points = p = (Vector3i *) MALLOC(sizeof(Vector3i) * s->npoints);
s->points = p = (Vector3i *) malloc(sizeof(Vector3i) * s->npoints);
if (p == NULL) {
return FALSE;
}
@ -873,7 +873,7 @@ static BOOL _imd_load_connectors(char **ppFileData, iIMDShape *s)
IMDConnectors+=s->nconnectors;
if ((s->connectors = (Vector3i *) MALLOC(sizeof(Vector3i) * s->nconnectors)) == NULL)
if ((s->connectors = (Vector3i *) malloc(sizeof(Vector3i) * s->nconnectors)) == NULL)
{
iV_Error(0xff,"(_load_connectors) MALLOC fail");
return FALSE;
@ -930,7 +930,7 @@ static iIMDShape *_imd_load_level(char **ppFileData, char *FileDataEnd, int nlev
if (nlevels == 0)
return NULL;
s = (iIMDShape *) MALLOC(sizeof(iIMDShape));
s = (iIMDShape *) malloc(sizeof(iIMDShape));
if (s) {
s->points = NULL;

View File

@ -544,7 +544,7 @@ static void pie_DrawShadow(iIMDShape *shape, int flag, int flag_data, Vector3f*
if(!edgelist)
{
edgelist = MALLOC(sizeof(EDGE)*edgelistsize);
edgelist = malloc(sizeof(EDGE)*edgelistsize);
}
pVertices = shape->points;
if( flag & pie_STATIC_SHADOW && shape->shadowEdgeList )
@ -577,9 +577,9 @@ static void pie_DrawShadow(iIMDShape *shape, int flag, int flag_data, Vector3f*
if(edge_count >= edgelistsize-1)
{
// enlarge
EDGE *newstack = MALLOC(sizeof(EDGE)*edgelistsize*2);
EDGE *newstack = malloc(sizeof(EDGE)*edgelistsize*2);
memcpy(newstack, edgelist, sizeof(EDGE)*edgelistsize);
FREE(edgelist);
free(edgelist);
edgelistsize*=2;
edgelist = newstack;
debug(LOG_WARNING, "new edge list size: %i", edgelistsize);

View File

@ -63,7 +63,7 @@ int pal_AddNewPalette(iColour *pal)
bPaletteInitialised = TRUE;
if (psGamePal == NULL)
{
psGamePal = (iColour*) MALLOC(PALETTE_SIZE * sizeof(iColour));
psGamePal = (iColour*) malloc(PALETTE_SIZE * sizeof(iColour));
if (psGamePal == NULL)
{
debug( LOG_ERROR, "pal_AddNewPalette - Out of memory" );
@ -118,7 +118,7 @@ void pal_ShutDown(void)
if (bPaletteInitialised)
{
bPaletteInitialised = FALSE;
FREE(psGamePal);
free(psGamePal);
}
}

View File

@ -83,7 +83,7 @@ void iV_SurfaceDestroy(iSurface *s)
psRendSurface = NULL;
if (s)
FREE(s);
free(s);
}
//*************************************************************************

View File

@ -341,7 +341,7 @@ BOOL image_load_from_jpg(pie_image* image, const char* filename)
if (setjmp(jerr.setjmp_buffer)) {
jpeg_destroy_decompress(&cinfo);
debug(LOG_ERROR, "Error during jpg decompression of \"%s\"!", filename);
FREE(buffer);
free(buffer);
return TRUE;
}
jpeg_read_header(&cinfo, TRUE);
@ -371,7 +371,7 @@ BOOL image_load_from_jpg(pie_image* image, const char* filename)
jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
FREE(buffer);
free(buffer);
return FALSE;
}
@ -469,7 +469,7 @@ void screen_SetBackDropFromFile(char* filename)
free(imagePNG.bmp);
}
FREE(buffer);
free(buffer);
return;
}
else

View File

@ -216,7 +216,7 @@ void pie_TexShutDown(void)
{
if(_TEX_PAGE[i].tex.bmp) {
j++;
FREE(_TEX_PAGE[i].tex.bmp);
free(_TEX_PAGE[i].tex.bmp);
}
}
i++;

View File

@ -204,11 +204,11 @@ void eventShutDown(void)
if (asCreateFuncs)
{
FREE(asCreateFuncs);
free(asCreateFuncs);
}
if (asReleaseFuncs)
{
FREE(asReleaseFuncs);
free(asReleaseFuncs);
}
}
@ -332,13 +332,13 @@ BOOL eventInitValueFuncs(SDWORD maxType)
ASSERT( asReleaseFuncs == NULL,
"eventInitValueFuncs: array already initialised" );
asCreateFuncs = (VAL_CREATE_FUNC *)MALLOC(sizeof(VAL_CREATE_FUNC) * maxType);
asCreateFuncs = (VAL_CREATE_FUNC *)malloc(sizeof(VAL_CREATE_FUNC) * maxType);
if (!asCreateFuncs)
{
debug(LOG_ERROR, "eventInitValueFuncs: Out of memory");
return FALSE;
}
asReleaseFuncs = (VAL_RELEASE_FUNC *)MALLOC(sizeof(VAL_RELEASE_FUNC) * maxType);
asReleaseFuncs = (VAL_RELEASE_FUNC *)malloc(sizeof(VAL_RELEASE_FUNC) * maxType);
if (!asReleaseFuncs)
{
debug(LOG_ERROR, "eventInitValueFuncs: Out of memory");
@ -422,7 +422,7 @@ BOOL eventNewContext(SCRIPT_CODE *psCode, CONTEXT_RELEASE release,
//prepare local variables (initialize, store type)
//-------------------------------
psCode->ppsLocalVarVal = (INTERP_VAL **)MALLOC(sizeof(INTERP_VAL*) * psCode->numEvents); //allocate space for array of local var arrays for each event
psCode->ppsLocalVarVal = (INTERP_VAL **)malloc(sizeof(INTERP_VAL*) * psCode->numEvents); //allocate space for array of local var arrays for each event
debug(LOG_SCRIPT,"allocated space for %d events", psCode->numEvents);
@ -430,7 +430,7 @@ BOOL eventNewContext(SCRIPT_CODE *psCode, CONTEXT_RELEASE release,
{
if(psCode->numLocalVars[i] > 0) //this event has any local vars declared
{
psCode->ppsLocalVarVal[i] = (INTERP_VAL*)MALLOC(sizeof(INTERP_VAL) * psCode->numLocalVars[i]); //allocate space for local vars array (for the current event)
psCode->ppsLocalVarVal[i] = (INTERP_VAL*)malloc(sizeof(INTERP_VAL) * psCode->numLocalVars[i]); //allocate space for local vars array (for the current event)
debug(LOG_SCRIPT,"Event %d has %d local variables", i, psCode->numLocalVars[i]);
@ -444,7 +444,7 @@ BOOL eventNewContext(SCRIPT_CODE *psCode, CONTEXT_RELEASE release,
memset to 0, the only special case is strings */
memset (&(psCode->ppsLocalVarVal[i][j]), 0, sizeof(INTERP_VAL));
if (type == VAL_STRING) {
psCode->ppsLocalVarVal[i][j].v.sval = (char*)MALLOC(MAXSTRLEN);
psCode->ppsLocalVarVal[i][j].v.sval = (char*)malloc(MAXSTRLEN);
strcpy(psCode->ppsLocalVarVal[i][j].v.sval,"\0");
}
@ -503,7 +503,7 @@ BOOL eventNewContext(SCRIPT_CODE *psCode, CONTEXT_RELEASE release,
// memset to 0
memset(&(psNewChunk->asVals[storeIndex]), 0, sizeof(INTERP_VAL));
if (type == VAL_STRING) {
psNewChunk->asVals[storeIndex].v.sval = (char*)MALLOC(MAXSTRLEN);
psNewChunk->asVals[storeIndex].v.sval = (char*)malloc(MAXSTRLEN);
strcpy(psNewChunk->asVals[storeIndex].v.sval,"\0");
}
@ -788,7 +788,7 @@ BOOL eventSetContextVar(SCRIPT_CONTEXT *psContext, UDWORD index, INTERP_VAL *dat
strcpy(psVal->v.sval, data->v.sval);
FREE(data->v.sval); //not needed anymore
free(data->v.sval); //not needed anymore
}
else
{

View File

@ -322,7 +322,7 @@ static BOOL eventLoadContext(SDWORD version, char *pBuffer, UDWORD *pSize, BOOL
size += sizeof(UDWORD);
break;
case VAL_STRING:
data.v.sval = (char*)MALLOC(MAXSTRLEN);
data.v.sval = (char*)malloc(MAXSTRLEN);
strcpy(data.v.sval, "\0");
stringLen = *((UDWORD *)pPos); //read string length
@ -603,7 +603,7 @@ BOOL eventSaveState(SDWORD version, char **ppBuffer, UDWORD *pFileSize)
// Allocate the buffer to save to
pBuffer = (char*)MALLOC(totalSize);
pBuffer = (char*)malloc(totalSize);
if (pBuffer == NULL)
{
debug( LOG_ERROR, "eventSaveState: out of memory" );

View File

@ -1169,7 +1169,7 @@ static inline void createVarEnvironment(SCRIPT_CONTEXT *psContext, UDWORD eventI
if (numEventVars > 0)
{
// alloc memory
varEnvironment[callDepth] = (INTERP_VAL *)MALLOC(sizeof(INTERP_VAL) * numEventVars);
varEnvironment[callDepth] = (INTERP_VAL *)malloc(sizeof(INTERP_VAL) * numEventVars);
// create environment
memcpy(varEnvironment[callDepth], psContext->psCode->ppsLocalVarVal[eventIndex], sizeof(INTERP_VAL) * numEventVars);
@ -1179,7 +1179,7 @@ static inline void createVarEnvironment(SCRIPT_CONTEXT *psContext, UDWORD eventI
{
if (varEnvironment[callDepth][i].type == VAL_STRING)
{
varEnvironment[callDepth][i].v.sval = (char*)MALLOC(MAXSTRLEN);
varEnvironment[callDepth][i].v.sval = (char*)malloc(MAXSTRLEN);
strcpy( varEnvironment[callDepth][i].v.sval, "" ); //initialize
}
}
@ -1207,12 +1207,12 @@ static inline void destroyVarEnvironment(SCRIPT_CONTEXT *psContext, UDWORD envIn
{
if (varEnvironment[envIndex][i].type == VAL_STRING)
{
FREE( varEnvironment[envIndex][i].v.sval );
free( varEnvironment[envIndex][i].v.sval );
varEnvironment[envIndex][i].v.sval = NULL;
}
}
FREE( varEnvironment[envIndex] );
free( varEnvironment[envIndex] );
}
}

View File

@ -86,34 +86,34 @@ void scriptFreeCode(SCRIPT_CODE *psCode)
{
if(psCode->ppsLocalVarVal[i][j].v.sval != NULL) //doublecheck..
{
FREE(psCode->ppsLocalVarVal[i][j].v.sval); //free string
free(psCode->ppsLocalVarVal[i][j].v.sval); //free string
}
}
}
FREE(psCode->ppsLocalVars[i]);
FREE(psCode->ppsLocalVarVal[i]); //free pointer to event i local vars
free(psCode->ppsLocalVars[i]);
free(psCode->ppsLocalVarVal[i]); //free pointer to event i local vars
}
}
FREE(psCode->pCode);
free(psCode->pCode);
if (psCode->pTriggerTab)
{
FREE(psCode->pTriggerTab);
free(psCode->pTriggerTab);
}
if (psCode->psTriggerData)
{
FREE(psCode->psTriggerData);
free(psCode->psTriggerData);
}
FREE(psCode->pEventTab);
FREE(psCode->pEventLinks);
free(psCode->pEventTab);
free(psCode->pEventLinks);
if (psCode->pGlobals != NULL)
{
FREE(psCode->pGlobals);
free(psCode->pGlobals);
}
if (psCode->psArrayInfo != NULL)
{
FREE(psCode->psArrayInfo);
free(psCode->psArrayInfo);
}
if (psCode->psDebug)
{
@ -121,10 +121,10 @@ void scriptFreeCode(SCRIPT_CODE *psCode)
{
if (psCode->psDebug[i].pLabel)
{
FREE(psCode->psDebug[i].pLabel);
free(psCode->psDebug[i].pLabel);
}
}
FREE(psCode->psDebug);
free(psCode->psDebug);
}
if (psCode->psVarDebug)
{
@ -132,10 +132,10 @@ void scriptFreeCode(SCRIPT_CODE *psCode)
{
if (psCode->psVarDebug[i].pIdent)
{
FREE(psCode->psVarDebug[i].pIdent);
free(psCode->psVarDebug[i].pIdent);
}
}
FREE(psCode->psVarDebug);
free(psCode->psVarDebug);
}
if (psCode->psArrayDebug)
{
@ -143,29 +143,29 @@ void scriptFreeCode(SCRIPT_CODE *psCode)
{
if (psCode->psArrayDebug[i].pIdent)
{
FREE(psCode->psArrayDebug[i].pIdent);
free(psCode->psArrayDebug[i].pIdent);
}
}
FREE(psCode->psArrayDebug);
free(psCode->psArrayDebug);
}
if(psCode->numParams != NULL)
FREE(psCode->numParams);
free(psCode->numParams);
if(psCode->numLocalVars != NULL)
FREE(psCode->numLocalVars);
free(psCode->numLocalVars);
if(psCode->ppsLocalVars != NULL)
FREE(psCode->ppsLocalVars);
free(psCode->ppsLocalVars);
if(psCode->ppsLocalVarVal != NULL)
FREE(psCode->ppsLocalVarVal);
free(psCode->ppsLocalVarVal);
psCode->numEvents = 0;
FREE(psCode);
free(psCode);
}

View File

@ -185,13 +185,13 @@ void script_debug(const char *pFormat, ...);
/* Macro to allocate a program structure, size is in _bytes_ */
#define ALLOC_PROG(psProg, codeSize, pAICode, numGlobs, numArys, numTrigs, numEvnts) \
(psProg) = (SCRIPT_CODE *)MALLOC(sizeof(SCRIPT_CODE)); \
(psProg) = (SCRIPT_CODE *)malloc(sizeof(SCRIPT_CODE)); \
if ((psProg) == NULL) \
{ \
debug(LOG_ERROR, "Out of memory"); \
ALLOC_ERROR_ACTION; \
} \
(psProg)->pCode = (INTERP_VAL *)MALLOC((codeSize) * sizeof(INTERP_VAL)); \
(psProg)->pCode = (INTERP_VAL *)malloc((codeSize) * sizeof(INTERP_VAL)); \
if ((psProg)->pCode == NULL) \
{ \
debug(LOG_ERROR, "Out of memory"); \
@ -199,7 +199,7 @@ void script_debug(const char *pFormat, ...);
} \
if (numGlobs > 0) \
{ \
(psProg)->pGlobals = (INTERP_TYPE *)MALLOC(sizeof(INTERP_TYPE) * (numGlobs)); \
(psProg)->pGlobals = (INTERP_TYPE *)malloc(sizeof(INTERP_TYPE) * (numGlobs)); \
if ((psProg)->pGlobals == NULL) \
{ \
debug(LOG_ERROR, "Out of memory"); \
@ -212,7 +212,7 @@ void script_debug(const char *pFormat, ...);
} \
if (numArys > 0) \
{ \
(psProg)->psArrayInfo = (ARRAY_DATA *)MALLOC(sizeof(ARRAY_DATA) * (numArys)); \
(psProg)->psArrayInfo = (ARRAY_DATA *)malloc(sizeof(ARRAY_DATA) * (numArys)); \
if ((psProg)->psArrayInfo == NULL) \
{ \
debug(LOG_ERROR, "Out of memory"); \
@ -226,13 +226,13 @@ void script_debug(const char *pFormat, ...);
(psProg)->numArrays = (UWORD)(numArys); \
if ((numTrigs) > 0) \
{ \
(psProg)->pTriggerTab = MALLOC(sizeof(UWORD) * ((numTrigs) + 1)); \
(psProg)->pTriggerTab = malloc(sizeof(UWORD) * ((numTrigs) + 1)); \
if ((psProg)->pTriggerTab == NULL) \
{ \
debug(LOG_ERROR, "Out of memory"); \
ALLOC_ERROR_ACTION; \
} \
(psProg)->psTriggerData = MALLOC(sizeof(TRIGGER_DATA) * (numTrigs)); \
(psProg)->psTriggerData = malloc(sizeof(TRIGGER_DATA) * (numTrigs)); \
if ((psProg)->psTriggerData == NULL) \
{ \
debug(LOG_ERROR, "Out of memory"); \
@ -244,13 +244,13 @@ void script_debug(const char *pFormat, ...);
(psProg)->pTriggerTab = NULL; \
(psProg)->psTriggerData = NULL; \
} \
(psProg)->pEventTab = MALLOC(sizeof(UWORD) * ((numEvnts) + 1)); \
(psProg)->pEventTab = malloc(sizeof(UWORD) * ((numEvnts) + 1)); \
if ((psProg)->pEventTab == NULL) \
{ \
debug(LOG_ERROR, "Out of memory"); \
ALLOC_ERROR_ACTION; \
} \
(psProg)->pEventLinks = MALLOC(sizeof(SWORD) * (numEvnts)); \
(psProg)->pEventLinks = malloc(sizeof(SWORD) * (numEvnts)); \
if ((psProg)->pEventLinks == NULL) \
{ \
debug(LOG_ERROR, "Out of memory"); \
@ -263,17 +263,17 @@ void script_debug(const char *pFormat, ...);
/* Macro to allocate a code block, blockSize - number of INTERP_VALs we need*/
#define ALLOC_BLOCK(psBlock, num) \
(psBlock) = (CODE_BLOCK *)MALLOC(sizeof(CODE_BLOCK)); \
(psBlock) = (CODE_BLOCK *)malloc(sizeof(CODE_BLOCK)); \
if ((psBlock) == NULL) \
{ \
debug(LOG_ERROR, "Out of memory"); \
ALLOC_ERROR_ACTION; \
} \
(psBlock)->pCode = (INTERP_VAL *)MALLOC((num) * sizeof(INTERP_VAL)); \
(psBlock)->pCode = (INTERP_VAL *)malloc((num) * sizeof(INTERP_VAL)); \
if ((psBlock)->pCode == NULL) \
{ \
debug(LOG_ERROR, "Out of memory"); \
FREE((psBlock)); \
free((psBlock)); \
ALLOC_ERROR_ACTION; \
} \
(psBlock)->size = (num); \
@ -281,30 +281,30 @@ void script_debug(const char *pFormat, ...);
/* Macro to free a code block */
#define FREE_BLOCK(psBlock) \
FREE((psBlock)->pCode); \
FREE((psBlock))
free((psBlock)->pCode); \
free((psBlock))
/* Macro to allocate a parameter block */
#define ALLOC_PBLOCK(psBlock, num, paramSize) \
(psBlock) = (PARAM_BLOCK *)MALLOC(sizeof(PARAM_BLOCK)); \
(psBlock) = (PARAM_BLOCK *)malloc(sizeof(PARAM_BLOCK)); \
if ((psBlock) == NULL) \
{ \
debug(LOG_ERROR, "Out of memory"); \
ALLOC_ERROR_ACTION; \
} \
(psBlock)->pCode = (INTERP_VAL *)MALLOC((num) * sizeof(INTERP_VAL)); \
(psBlock)->pCode = (INTERP_VAL *)malloc((num) * sizeof(INTERP_VAL)); \
if ((psBlock)->pCode == NULL) \
{ \
debug(LOG_ERROR, "Out of memory"); \
FREE((psBlock)); \
free((psBlock)); \
ALLOC_ERROR_ACTION; \
} \
(psBlock)->aParams = (INTERP_TYPE *)MALLOC(sizeof(INTERP_TYPE) * (paramSize)); \
(psBlock)->aParams = (INTERP_TYPE *)malloc(sizeof(INTERP_TYPE) * (paramSize)); \
if ((psBlock)->aParams == NULL) \
{ \
debug(LOG_ERROR, "Out of memory"); \
FREE((psBlock)->pCode); \
FREE((psBlock)); \
free((psBlock)->pCode); \
free((psBlock)); \
ALLOC_ERROR_ACTION; \
} \
(psBlock)->size = (num); \
@ -312,19 +312,19 @@ void script_debug(const char *pFormat, ...);
/* Macro to free a parameter block */
#define FREE_PBLOCK(psBlock) \
FREE((psBlock)->pCode); \
FREE((psBlock)->aParams); \
FREE((psBlock))
free((psBlock)->pCode); \
free((psBlock)->aParams); \
free((psBlock))
/* Macro to allocate a parameter declaration block */
#define ALLOC_PARAMDECL(psPDecl, num) \
(psPDecl) = (PARAM_DECL *)MALLOC(sizeof(PARAM_DECL)); \
(psPDecl) = (PARAM_DECL *)malloc(sizeof(PARAM_DECL)); \
if ((psPDecl) == NULL) \
{ \
debug(LOG_ERROR, "Out of memory"); \
ALLOC_ERROR_ACTION; \
} \
(psPDecl)->aParams = (INTERP_TYPE *)MALLOC(sizeof(INTERP_TYPE) * (num)); \
(psPDecl)->aParams = (INTERP_TYPE *)malloc(sizeof(INTERP_TYPE) * (num)); \
if ((psPDecl)->aParams == NULL) \
{ \
debug(LOG_ERROR, "Out of memory"); \
@ -334,24 +334,24 @@ void script_debug(const char *pFormat, ...);
/* Macro to free a parameter declaration block */
#define FREE_PARAMDECL(psPDecl) \
FREE((psPDecl)->aParams); \
FREE((psPDecl))
free((psPDecl)->aParams); \
free((psPDecl))
/* Macro to allocate a conditional block */
#define ALLOC_CONDBLOCK(psCB, num, numBlocks) \
(psCB) = (COND_BLOCK *)MALLOC(sizeof(COND_BLOCK)); \
(psCB) = (COND_BLOCK *)malloc(sizeof(COND_BLOCK)); \
if ((psCB) == NULL) \
{ \
debug(LOG_ERROR, "Out of memory"); \
ALLOC_ERROR_ACTION; \
} \
(psCB)->aOffsets = (UDWORD *)MALLOC(sizeof(SDWORD) * (num)); \
(psCB)->aOffsets = (UDWORD *)malloc(sizeof(SDWORD) * (num)); \
if ((psCB)->aOffsets == NULL) \
{ \
debug(LOG_ERROR, "Out of memory"); \
ALLOC_ERROR_ACTION; \
} \
(psCB)->pCode = (INTERP_VAL *)MALLOC((numBlocks) * sizeof(INTERP_VAL)); \
(psCB)->pCode = (INTERP_VAL *)malloc((numBlocks) * sizeof(INTERP_VAL)); \
if ((psCB)->pCode == NULL) \
{ \
debug(LOG_ERROR, "Out of memory"); \
@ -362,24 +362,24 @@ void script_debug(const char *pFormat, ...);
/* Macro to free a conditional block */
#define FREE_CONDBLOCK(psCB) \
FREE((psCB)->aOffsets); \
FREE((psCB)->pCode); \
FREE(psCB)
free((psCB)->aOffsets); \
free((psCB)->pCode); \
free(psCB)
/* Macro to free a code block */
#define FREE_USERBLOCK(psBlock) \
FREE((psBlock)->pCode); \
FREE((psBlock))
free((psBlock)->pCode); \
free((psBlock))
/* Macro to allocate an object variable block */
#define ALLOC_OBJVARBLOCK(psOV, blockSize, psVar) \
(psOV) = (OBJVAR_BLOCK *)MALLOC(sizeof(OBJVAR_BLOCK)); \
(psOV) = (OBJVAR_BLOCK *)malloc(sizeof(OBJVAR_BLOCK)); \
if ((psOV) == NULL) \
{ \
scr_error("Out of memory"); \
ALLOC_ERROR_ACTION; \
} \
(psOV)->pCode = (INTERP_VAL *)MALLOC((blockSize) * sizeof(INTERP_VAL)); \
(psOV)->pCode = (INTERP_VAL *)malloc((blockSize) * sizeof(INTERP_VAL)); \
if ((psOV)->pCode == NULL) \
{ \
scr_error("Out of memory"); \
@ -390,18 +390,18 @@ void script_debug(const char *pFormat, ...);
/* Macro to free an object variable block */
#define FREE_OBJVARBLOCK(psOV) \
FREE((psOV)->pCode); \
FREE(psOV)
free((psOV)->pCode); \
free(psOV)
/* Macro to allocate an array variable block */
#define ALLOC_ARRAYBLOCK(psAV, blockSize, psVar) \
(psAV) = (ARRAY_BLOCK *)MALLOC(sizeof(ARRAY_BLOCK)); \
(psAV) = (ARRAY_BLOCK *)malloc(sizeof(ARRAY_BLOCK)); \
if ((psAV) == NULL) \
{ \
scr_error("Out of memory"); \
ALLOC_ERROR_ACTION; \
} \
(psAV)->pCode = (INTERP_VAL *)MALLOC((blockSize) * sizeof(INTERP_VAL)); \
(psAV)->pCode = (INTERP_VAL *)malloc((blockSize) * sizeof(INTERP_VAL)); \
if ((psAV)->pCode == NULL) \
{ \
scr_error("Out of memory"); \
@ -413,12 +413,12 @@ void script_debug(const char *pFormat, ...);
/* Macro to free an object variable block */
#define FREE_ARRAYBLOCK(psAV) \
FREE((psAV)->pCode); \
FREE(psAV)
free((psAV)->pCode); \
free(psAV)
/* Allocate a trigger subdecl */
#define ALLOC_TSUBDECL(psTSub, blockType, blockSize, blockTime) \
(psTSub) = MALLOC(sizeof(TRIGGER_DECL)); \
(psTSub) = malloc(sizeof(TRIGGER_DECL)); \
if ((psTSub) == NULL) \
{ \
scr_error("Out of memory"); \
@ -428,7 +428,7 @@ void script_debug(const char *pFormat, ...);
(psTSub)->time = (blockTime); \
if ((blockSize) > 0) \
{ \
(psTSub)->pCode = (INTERP_VAL *)MALLOC((blockSize) * sizeof(INTERP_VAL)); \
(psTSub)->pCode = (INTERP_VAL *)malloc((blockSize) * sizeof(INTERP_VAL)); \
if ((psTSub)->pCode == NULL) \
{ \
scr_error("Out of memory"); \
@ -446,13 +446,13 @@ void script_debug(const char *pFormat, ...);
#define FREE_TSUBDECL(psTSub) \
if ((psTSub)->pCode) \
{ \
FREE((psTSub)->pCode); \
free((psTSub)->pCode); \
} \
FREE(psTSub)
free(psTSub)
/* Allocate a variable declaration block */
#define ALLOC_VARDECL(psDcl) \
(psDcl)=MALLOC(sizeof(VAR_DECL)); \
(psDcl)=malloc(sizeof(VAR_DECL)); \
if ((psDcl) == NULL) \
{ \
scr_error("Out of memory"); \
@ -461,11 +461,11 @@ void script_debug(const char *pFormat, ...);
/* Free a variable declaration block */
#define FREE_VARDECL(psDcl) \
FREE(psDcl)
free(psDcl)
/* Allocate a variable declaration block */
#define ALLOC_VARIDENTDECL(psDcl, ident, dim) \
(psDcl)=MALLOC(sizeof(VAR_IDENT_DECL)); \
(psDcl)=malloc(sizeof(VAR_IDENT_DECL)); \
if ((psDcl) == NULL) \
{ \
scr_error("Out of memory"); \
@ -473,7 +473,7 @@ void script_debug(const char *pFormat, ...);
} \
if ((ident) != NULL) \
{ \
(psDcl)->pIdent=MALLOC(strlen(ident)+1); \
(psDcl)->pIdent=malloc(strlen(ident)+1); \
if ((psDcl)->pIdent == NULL) \
{ \
scr_error("Out of memory"); \
@ -489,7 +489,7 @@ void script_debug(const char *pFormat, ...);
/* Free a variable declaration block */
#define FREE_VARIDENTDECL(psDcl) \
FREE(psDcl)
free(psDcl)
/****************************************************************************************
*
@ -593,7 +593,7 @@ void script_debug(const char *pFormat, ...);
#define ALLOC_DEBUG(psBlock, num) \
if (genDebugInfo) \
{ \
(psBlock)->psDebug = (SCRIPT_DEBUG *)MALLOC(sizeof(SCRIPT_DEBUG) * (num)); \
(psBlock)->psDebug = (SCRIPT_DEBUG *)malloc(sizeof(SCRIPT_DEBUG) * (num)); \
if ((psBlock)->psDebug == NULL) \
{ \
scr_error("Out of memory"); \
@ -611,7 +611,7 @@ void script_debug(const char *pFormat, ...);
/* Macro to free debugging info */
#define FREE_DEBUG(psBlock) \
if (genDebugInfo) \
FREE((psBlock)->psDebug)
free((psBlock)->psDebug)
/* Macro to copy the debugging information from one block to another */
@ -660,7 +660,7 @@ static SCRIPT_DEBUG *_psCurr;
#define DEBUG_LABEL(psBlock, offset, pString) \
if (genDebugInfo) \
{ \
(psBlock)->psDebug[offset].pLabel = MALLOC(strlen(pString)+1); \
(psBlock)->psDebug[offset].pLabel = malloc(strlen(pString)+1); \
if (!(psBlock)->psDebug[offset].pLabel) \
{ \
scr_error("Out of memory"); \
@ -1980,10 +1980,10 @@ script: header var_list
//store local vars
//allocate array for holding an array of local vars for each event
psFinalProg->ppsLocalVars = (INTERP_TYPE **)MALLOC(sizeof(INTERP_TYPE*) * numEvents);
psFinalProg->ppsLocalVars = (INTERP_TYPE **)malloc(sizeof(INTERP_TYPE*) * numEvents);
psFinalProg->ppsLocalVarVal = NULL;
psFinalProg->numLocalVars = (UDWORD *)MALLOC(sizeof(UDWORD) * numEvents); //how many local vars each event has
psFinalProg->numParams = (UDWORD *)MALLOC(sizeof(UDWORD) * numEvents); //how many arguments each event has
psFinalProg->numLocalVars = (UDWORD *)malloc(sizeof(UDWORD) * numEvents); //how many local vars each event has
psFinalProg->numParams = (UDWORD *)malloc(sizeof(UDWORD) * numEvents); //how many arguments each event has
i=0;
for(psEvent = psEvents; psEvent; psEvent = psEvent->psNext)
@ -1995,7 +1995,7 @@ script: header var_list
if(numEventLocalVars[i] > 0)
{
pCurEvLocalVars = (INTERP_TYPE*)MALLOC(sizeof(INTERP_TYPE) * numEventLocalVars[i]);
pCurEvLocalVars = (INTERP_TYPE*)malloc(sizeof(INTERP_TYPE) * numEventLocalVars[i]);
j=0;
for(psCurr =psLocalVarsB[i]; psCurr != NULL; psCurr = psCurr->psNext)
@ -2083,7 +2083,7 @@ script: header var_list
{
if (numVars > 0)
{
psFinalProg->psVarDebug = MALLOC(sizeof(VAR_DEBUG) * numVars);
psFinalProg->psVarDebug = malloc(sizeof(VAR_DEBUG) * numVars);
if (psFinalProg->psVarDebug == NULL)
{
scr_error("Out of memory");
@ -2096,7 +2096,7 @@ script: header var_list
}
if (numArrays > 0)
{
psFinalProg->psArrayDebug = MALLOC(sizeof(ARRAY_DEBUG) * numArrays);
psFinalProg->psArrayDebug = malloc(sizeof(ARRAY_DEBUG) * numArrays);
if (psFinalProg->psArrayDebug == NULL)
{
scr_error("Out of memory");
@ -2123,7 +2123,7 @@ script: header var_list
if (genDebugInfo)
{
psFinalProg->psVarDebug[i].pIdent =
MALLOC(strlen(psCurr->pIdent) + 1);
malloc(strlen(psCurr->pIdent) + 1);
if (psFinalProg->psVarDebug[i].pIdent == NULL)
{
scr_error("Out of memory");
@ -2150,7 +2150,7 @@ script: header var_list
if (genDebugInfo)
{
psFinalProg->psArrayDebug[i].pIdent =
MALLOC(strlen(psCurr->pIdent) + 1);
malloc(strlen(psCurr->pIdent) + 1);
if (psFinalProg->psArrayDebug[i].pIdent == NULL)
{
scr_error("Out of memory");
@ -2315,7 +2315,7 @@ variable_ident: IDENT
|
IDENT array_sub_decl_list
{
$2->pIdent = MALLOC(strlen($1)+1);
$2->pIdent = malloc(strlen($1)+1);
if ($2->pIdent == NULL)
{
scr_error("Out of memory");
@ -5750,8 +5750,8 @@ static void scriptResetTables(void)
for(psCurr = psGlobalVars; psCurr != NULL; psCurr = psNext)
{
psNext = psCurr->psNext;
FREE(psCurr->pIdent);
FREE(psCurr);
free(psCurr->pIdent);
free(psCurr);
}
psGlobalVars = NULL;
@ -5764,8 +5764,8 @@ static void scriptResetTables(void)
for(psCurr = psLocalVarsB[i]; psCurr != NULL; psCurr = psNext)
{
psNext = psCurr->psNext;
FREE(psCurr->pIdent);
FREE(psCurr);
free(psCurr->pIdent);
free(psCurr);
}
psLocalVarsB[i] = NULL;
}
@ -5774,8 +5774,8 @@ static void scriptResetTables(void)
for(psCurr = psLocalVarsTemp; psCurr != NULL; psCurr = psNext)
{
psNext = psCurr->psNext;
FREE(psCurr->pIdent);
FREE(psCurr);
free(psCurr->pIdent);
free(psCurr);
}
psLocalVarsTemp = NULL;
@ -5784,8 +5784,8 @@ static void scriptResetTables(void)
for(psCurr = psGlobalArrays; psCurr != NULL; psCurr = psNext)
{
psNext = psCurr->psNext;
FREE(psCurr->pIdent);
FREE(psCurr);
free(psCurr->pIdent);
free(psCurr);
}
psGlobalArrays = NULL;
@ -5795,14 +5795,14 @@ static void scriptResetTables(void)
psTNext = psTCurr->psNext;
if (psTCurr->psDebug)
{
FREE(psTCurr->psDebug);
free(psTCurr->psDebug);
}
if (psTCurr->pCode)
{
FREE(psTCurr->pCode);
free(psTCurr->pCode);
}
FREE(psTCurr->pIdent);
FREE(psTCurr);
free(psTCurr->pIdent);
free(psTCurr);
}
psTriggers = NULL;
numTriggers = 0;
@ -5813,11 +5813,11 @@ static void scriptResetTables(void)
psENext = psECurr->psNext;
if (psECurr->psDebug)
{
FREE(psECurr->psDebug);
free(psECurr->psDebug);
}
FREE(psECurr->pIdent);
FREE(psECurr->pCode);
FREE(psECurr);
free(psECurr->pIdent);
free(psECurr->pCode);
free(psECurr);
}
psEvents = NULL;
numEvents = 0;
@ -5827,9 +5827,9 @@ static void scriptResetTables(void)
{
psFNext = psFCurr->psNext;
FREE_DEBUG(psFCurr);
FREE(psFCurr->pIdent);
FREE(psFCurr->pCode);
FREE(psFCurr);
free(psFCurr->pIdent);
free(psFCurr->pCode);
free(psFCurr);
}
psFunctions = NULL;
}
@ -5955,8 +5955,8 @@ void scriptClearLocalVariables(void)
for(psCurr = psLocalVars; psCurr != NULL; psCurr = psNext)
{
psNext = psCurr->psNext;
FREE(psCurr->pIdent);
FREE(psCurr);
free(psCurr->pIdent);
free(psCurr);
}
}
@ -5985,14 +5985,14 @@ BOOL scriptAddVariable(VAR_DECL *psStorage, VAR_IDENT_DECL *psVarIdent)
SDWORD i;
/* Allocate the memory for the symbol structure */
psNew = (VAR_SYMBOL *)MALLOC(sizeof(VAR_SYMBOL));
psNew = (VAR_SYMBOL *)malloc(sizeof(VAR_SYMBOL));
if (psNew == NULL)
{
scr_error("Out of memory");
return FALSE;
}
psNew->pIdent = psVarIdent->pIdent; //(char *)MALLOC(strlen(pIdent) + 1);
psNew->pIdent = psVarIdent->pIdent; //(char *)malloc(strlen(pIdent) + 1);
/* if (psNew->pIdent == NULL)
{
scr_error("Out of memory");
@ -6196,13 +6196,13 @@ BOOL scriptAddTrigger(const char *pIdent, TRIGGER_DECL *psDecl, UDWORD line)
TRIGGER_SYMBOL *psTrigger, *psCurr, *psPrev;
// Allocate the trigger
psTrigger = MALLOC(sizeof(TRIGGER_SYMBOL));
psTrigger = malloc(sizeof(TRIGGER_SYMBOL));
if (!psTrigger)
{
scr_error("Out of memory");
return FALSE;
}
psTrigger->pIdent = MALLOC(strlen(pIdent) + 1);
psTrigger->pIdent = malloc(strlen(pIdent) + 1);
if (!psTrigger->pIdent)
{
scr_error("Out of memory");
@ -6211,7 +6211,7 @@ BOOL scriptAddTrigger(const char *pIdent, TRIGGER_DECL *psDecl, UDWORD line)
strcpy(psTrigger->pIdent, pIdent);
if (psDecl->size > 0)
{
psTrigger->pCode = (INTERP_VAL *)MALLOC(psDecl->size * sizeof(INTERP_VAL));
psTrigger->pCode = (INTERP_VAL *)malloc(psDecl->size * sizeof(INTERP_VAL));
if (!psTrigger->pCode)
{
scr_error("Out of memory");
@ -6232,7 +6232,7 @@ BOOL scriptAddTrigger(const char *pIdent, TRIGGER_DECL *psDecl, UDWORD line)
// Add debug info
if (genDebugInfo)
{
psTrigger->psDebug = MALLOC(sizeof(SCRIPT_DEBUG));
psTrigger->psDebug = malloc(sizeof(SCRIPT_DEBUG));
psTrigger->psDebug[0].offset = 0;
psTrigger->psDebug[0].line = line;
psTrigger->debugEntries = 1;
@ -6318,13 +6318,13 @@ BOOL scriptDeclareEvent(const char *pIdent, EVENT_SYMBOL **ppsEvent, SDWORD numA
EVENT_SYMBOL *psEvent, *psCurr, *psPrev;
// Allocate the event
psEvent = MALLOC(sizeof(EVENT_SYMBOL));
psEvent = malloc(sizeof(EVENT_SYMBOL));
if (!psEvent)
{
scr_error("Out of memory");
return FALSE;
}
psEvent->pIdent = MALLOC(strlen(pIdent) + 1);
psEvent->pIdent = malloc(strlen(pIdent) + 1);
if (!psEvent->pIdent)
{
scr_error("Out of memory");
@ -6376,7 +6376,7 @@ BOOL scriptDefineEvent(EVENT_SYMBOL *psEvent, CODE_BLOCK *psCode, SDWORD trigger
"Events with parameters can't have a trigger assigned, event: '%s' ", psEvent->pIdent);
// Store the event code
psEvent->pCode = (INTERP_VAL *)MALLOC(psCode->size * sizeof(INTERP_VAL));
psEvent->pCode = (INTERP_VAL *)malloc(psCode->size * sizeof(INTERP_VAL));
if (!psEvent->pCode)
{
scr_error("Out of memory");
@ -6390,7 +6390,7 @@ BOOL scriptDefineEvent(EVENT_SYMBOL *psEvent, CODE_BLOCK *psCode, SDWORD trigger
// Add debug info
if (genDebugInfo && (psCode->debugEntries > 0))
{
psEvent->psDebug = MALLOC(sizeof(SCRIPT_DEBUG) * psCode->debugEntries);
psEvent->psDebug = malloc(sizeof(SCRIPT_DEBUG) * psCode->debugEntries);
if (!psEvent->psDebug)
{

View File

@ -83,15 +83,15 @@ static BOOL stackNewChunk(UDWORD size)
else
{
/* Allocate a new chunk */
psCurrChunk->psNext = (STACK_CHUNK *)MALLOC(sizeof(STACK_CHUNK));
psCurrChunk->psNext = (STACK_CHUNK *)malloc(sizeof(STACK_CHUNK));
if (!psCurrChunk->psNext)
{
return FALSE;
}
psCurrChunk->psNext->aVals = (INTERP_VAL*)MALLOC(sizeof(INTERP_VAL) * size);
psCurrChunk->psNext->aVals = (INTERP_VAL*)malloc(sizeof(INTERP_VAL) * size);
if (!psCurrChunk->psNext->aVals)
{
FREE(psCurrChunk->psNext);
free(psCurrChunk->psNext);
return FALSE;
}
@ -122,7 +122,7 @@ BOOL stackPush(INTERP_VAL *psVal)
{
/* strings should already have memory allocated */
if(psCurrChunk->aVals[currEntry].type != VAL_STRING) //needs to have memory allocated for string
psCurrChunk->aVals[currEntry].v.sval = (char*)MALLOC(MAXSTRLEN);
psCurrChunk->aVals[currEntry].v.sval = (char*)malloc(MAXSTRLEN);
strcpy(psCurrChunk->aVals[currEntry].v.sval, psVal->v.sval); //copy string to stack
psCurrChunk->aVals[currEntry].type = VAL_STRING;
@ -131,7 +131,7 @@ BOOL stackPush(INTERP_VAL *psVal)
{
/* free stack var allocated string memory, if stack var used to be of type VAL_STRING */
if(psCurrChunk->aVals[currEntry].type == VAL_STRING)
FREE(psCurrChunk->aVals[currEntry].v.sval); //don't need it anymore
free(psCurrChunk->aVals[currEntry].v.sval); //don't need it anymore
/* copy type/data as union */
memcpy(&(psCurrChunk->aVals[currEntry]), psVal, sizeof(INTERP_VAL));
@ -444,7 +444,7 @@ BOOL stackPushResult(INTERP_TYPE type, INTERP_VAL *result)
{
/* strings should already have memory allocated */
if(psCurrChunk->aVals[currEntry].type != VAL_STRING) //needs to have memory allocated for string
psCurrChunk->aVals[currEntry].v.sval = (char*)MALLOC(MAXSTRLEN);
psCurrChunk->aVals[currEntry].v.sval = (char*)malloc(MAXSTRLEN);
strcpy(psCurrChunk->aVals[currEntry].v.sval, result->v.sval); //copy string to stack
psCurrChunk->aVals[currEntry].type = VAL_STRING;
@ -453,7 +453,7 @@ BOOL stackPushResult(INTERP_TYPE type, INTERP_VAL *result)
{
/* free stack var allocated string memory, if stack var used to be of type VAL_STRING */
if(psCurrChunk->aVals[currEntry].type == VAL_STRING)
FREE(psCurrChunk->aVals[currEntry].v.sval); //don't need it anymore
free(psCurrChunk->aVals[currEntry].v.sval); //don't need it anymore
/* copy type/data as union */
memcpy(&(psCurrChunk->aVals[currEntry]), result, sizeof(INTERP_VAL));
@ -716,19 +716,19 @@ BOOL stackBinaryOp(OPCODE opcode)
case VAL_INT: //first value isn't string, but can be converted to string
sprintf(tempstr1,"%d",psV1->v.ival); //int->string
psV1->type = VAL_STRING; //Mark as string
psV1->v.sval = (char*)MALLOC(MAXSTRLEN); //allocate space for the string, since the result (string) of concatenation will be saved here
psV1->v.sval = (char*)malloc(MAXSTRLEN); //allocate space for the string, since the result (string) of concatenation will be saved here
break;
case VAL_BOOL:
sprintf(tempstr1,"%d",psV1->v.bval); //bool->string
psV1->type = VAL_STRING; //Mark as string
psV1->v.sval = (char*)MALLOC(MAXSTRLEN); //allocate space for the string, since the result (string) of concatenation will be saved here
psV1->v.sval = (char*)malloc(MAXSTRLEN); //allocate space for the string, since the result (string) of concatenation will be saved here
break;
case VAL_FLOAT:
sprintf(tempstr1,"%f",psV1->v.fval); //float->string
psV1->type = VAL_STRING; //Mark as string
psV1->v.sval = (char*)MALLOC(MAXSTRLEN); //allocate space for the string, since the result (string) of concatenation will be saved here
psV1->v.sval = (char*)malloc(MAXSTRLEN); //allocate space for the string, since the result (string) of concatenation will be saved here
break;
case VAL_STRING:
@ -973,14 +973,14 @@ BOOL castTop(INTERP_TYPE neededType)
/* Initialise the stack */
BOOL stackInitialise(void)
{
psStackBase = (STACK_CHUNK *)MALLOC(sizeof(STACK_CHUNK));
psStackBase = (STACK_CHUNK *)malloc(sizeof(STACK_CHUNK));
if (psStackBase == NULL)
{
debug( LOG_ERROR, "Out of memory" );
abort();
return FALSE;
}
psStackBase->aVals = (INTERP_VAL*)MALLOC(sizeof(INTERP_VAL) * INIT_SIZE);
psStackBase->aVals = (INTERP_VAL*)malloc(sizeof(INTERP_VAL) * INIT_SIZE);
if (!psStackBase->aVals)
{
debug( LOG_ERROR, "Out of memory" );
@ -1028,7 +1028,7 @@ void stackShutDown(void)
if(psCurr->aVals[i].v.sval != NULL) //FIXME: seems to be causing problems sometimes
{
debug(LOG_WZ, "freeing '%s' ", psCurr->aVals[i].v.sval);
FREE(psCurr->aVals[i].v.sval);
free(psCurr->aVals[i].v.sval);
psCurr->aVals[i].v.sval = NULL;
}
else
@ -1038,8 +1038,8 @@ void stackShutDown(void)
}
}
FREE(psCurr->aVals);
FREE(psCurr);
free(psCurr->aVals);
free(psCurr);
}
}

View File

@ -64,7 +64,7 @@ BOOL barGraphCreate(W_BARGRAPH **ppsWidget, W_BARINIT *psInit)
/* Allocate the required memory */
#if W_USE_MALLOC
*ppsWidget = (W_BARGRAPH *)MALLOC(sizeof(W_BARGRAPH));
*ppsWidget = (W_BARGRAPH *)malloc(sizeof(W_BARGRAPH));
if (*ppsWidget == NULL)
#else
if (!HEAP_ALLOC(psBarHeap, (void**) ppsWidget))
@ -158,7 +158,7 @@ void barGraphFree(W_BARGRAPH *psWidget)
#endif
#if W_USE_MALLOC
FREE(psWidget);
free(psWidget);
#else
HEAP_FREE(psBarHeap, psWidget);
#endif

View File

@ -55,7 +55,7 @@ BOOL buttonCreate(W_BUTTON **ppsWidget, W_BUTINIT *psInit)
/* Allocate the required memory */
#if W_USE_MALLOC
*ppsWidget = (W_BUTTON *)MALLOC(sizeof(W_BUTTON));
*ppsWidget = (W_BUTTON *)malloc(sizeof(W_BUTTON));
if (*ppsWidget == NULL)
#else
if (!HEAP_ALLOC(psButHeap, (void**) ppsWidget))
@ -72,7 +72,7 @@ BOOL buttonCreate(W_BUTTON **ppsWidget, W_BUTINIT *psInit)
{
ASSERT( FALSE, "buttonCreate: Out of memory" );
#if W_USE_MALLOC
FREE(*ppsWidget);
free(*ppsWidget);
#else
HEAP_FREE(psButHeap, *ppsWidget);
#endif
@ -156,7 +156,7 @@ void buttonFree(W_BUTTON *psWidget)
#endif
#if W_USE_MALLOC
FREE(psWidget);
free(psWidget);
#else
HEAP_FREE(psButHeap, psWidget);
#endif

View File

@ -69,7 +69,7 @@ BOOL editBoxCreate(W_EDITBOX **ppsWidget, W_EDBINIT *psInit)
/* Allocate the required memory */
#if W_USE_MALLOC
*ppsWidget = (W_EDITBOX *)MALLOC(sizeof(W_EDITBOX));
*ppsWidget = (W_EDITBOX *)malloc(sizeof(W_EDITBOX));
if (*ppsWidget == NULL)
#else
if (!HEAP_ALLOC(psEdbHeap, (void**) ppsWidget))
@ -128,7 +128,7 @@ BOOL editBoxCreate(W_EDITBOX **ppsWidget, W_EDBINIT *psInit)
void editBoxFree(W_EDITBOX *psWidget)
{
#if W_USE_MALLOC
FREE(psWidget);
free(psWidget);
#else
HEAP_FREE(psEdbHeap, psWidget);
#endif

View File

@ -105,7 +105,7 @@ static BOOL formCreatePlain(W_FORM **ppsWidget, W_FORMINIT *psInit)
{
/* Allocate the required memory */
#if W_USE_MALLOC
*ppsWidget = (W_FORM *)MALLOC(sizeof(W_FORM));
*ppsWidget = (W_FORM *)malloc(sizeof(W_FORM));
if (*ppsWidget == NULL)
#else
if (!HEAP_ALLOC(psFormHeap, (void**) ppsWidget))
@ -157,7 +157,7 @@ static void formFreePlain(W_FORM *psWidget)
widgReleaseWidgetList(psWidget->psWidgets);
#if W_USE_MALLOC
FREE(psWidget);
free(psWidget);
#else
HEAP_FREE(psFormHeap, psWidget);
#endif
@ -169,7 +169,7 @@ static BOOL formCreateClickable(W_CLICKFORM **ppsWidget, W_FORMINIT *psInit)
{
/* Allocate the required memory */
#if W_USE_MALLOC
*ppsWidget = (W_CLICKFORM *)MALLOC(sizeof(W_CLICKFORM));
*ppsWidget = (W_CLICKFORM *)malloc(sizeof(W_CLICKFORM));
if (*ppsWidget == NULL)
#else
if (!HEAP_ALLOC(psCFormHeap, (void**) ppsWidget))
@ -216,7 +216,7 @@ static BOOL formCreateClickable(W_CLICKFORM **ppsWidget, W_FORMINIT *psInit)
{
ASSERT( FALSE, "formCreateClickable: Out of string memory" );
#if W_USE_MALLOC
FREE(*ppsWidget);
free(*ppsWidget);
#else
HEAP_FREE(psCFormHeap, *ppsWidget);
#endif
@ -252,7 +252,7 @@ static void formFreeClickable(W_CLICKFORM *psWidget)
#endif
#if W_USE_MALLOC
FREE(psWidget);
free(psWidget);
#else
HEAP_FREE(psCFormHeap, psWidget);
#endif
@ -296,7 +296,7 @@ static BOOL formCreateTabbed(W_TABFORM **ppsWidget, W_FORMINIT *psInit)
/* Allocate the required memory */
#if W_USE_MALLOC
*ppsWidget = (W_TABFORM *)MALLOC(sizeof(W_TABFORM));
*ppsWidget = (W_TABFORM *)malloc(sizeof(W_TABFORM));
if (*ppsWidget == NULL)
#else
if (!HEAP_ALLOC(psTFormHeap, (void**) ppsWidget))
@ -437,7 +437,7 @@ static void formFreeTabbed(W_TABFORM *psWidget)
psCurr = formGetAllWidgets(&sGetAll);
}
#if W_USE_MALLOC
FREE(psWidget);
free(psWidget);
#else
HEAP_FREE(psTFormHeap, psWidget);
#endif

View File

@ -49,7 +49,7 @@ BOOL labelCreate(W_LABEL **ppsWidget, W_LABINIT *psInit)
/* Allocate the required memory */
#if W_USE_MALLOC
*ppsWidget = (W_LABEL *)MALLOC(sizeof(W_LABEL));
*ppsWidget = (W_LABEL *)malloc(sizeof(W_LABEL));
if (*ppsWidget == NULL)
#else
if (!HEAP_ALLOC(psLabHeap, (void**) ppsWidget))
@ -127,7 +127,7 @@ void labelFree(W_LABEL *psWidget)
"labelFree: Invalid label pointer" );
#if W_USE_MALLOC
FREE(psWidget);
free(psWidget);
#else
HEAP_FREE(psLabHeap, psWidget);
#endif

View File

@ -80,7 +80,7 @@ BOOL sliderCreate(W_SLIDER **ppsWidget, W_SLDINIT *psInit)
/* Allocate the required memory */
#if W_USE_MALLOC
*ppsWidget = (W_SLIDER *)MALLOC(sizeof(W_SLIDER));
*ppsWidget = (W_SLIDER *)malloc(sizeof(W_SLIDER));
if (*ppsWidget == NULL)
#else
if (!HEAP_ALLOC(psSldHeap, (void**) ppsWidget))
@ -156,7 +156,7 @@ void sliderFree(W_SLIDER *psWidget)
#if W_USE_MALLOC
FREE(psWidget);
free(psWidget);
#else
HEAP_FREE(psSldHeap, psWidget);
#endif

View File

@ -218,7 +218,7 @@ BOOL widgCreateScreen(W_SCREEN **ppsScreen)
W_FORM *psForm;
W_FORMINIT sInit;
*ppsScreen = (W_SCREEN *)MALLOC(sizeof(W_SCREEN));
*ppsScreen = (W_SCREEN *)malloc(sizeof(W_SCREEN));
if (*ppsScreen == NULL)
{
ASSERT( FALSE, "Out of memory" );
@ -289,7 +289,7 @@ void widgReleaseScreen(W_SCREEN *psScreen)
formFree((W_FORM *)psScreen->psForm);
FREE(psScreen);
free(psScreen);
}

View File

@ -143,7 +143,7 @@ BOOL astarInitialise(void)
}
#if OPEN_LIST == 2
apsNodes = (FP_NODE**)MALLOC(sizeof(FP_NODE *) * FPATH_TABLESIZE);
apsNodes = (FP_NODE**)malloc(sizeof(FP_NODE *) * FPATH_TABLESIZE);
if (!apsNodes)
{
return FALSE;
@ -151,13 +151,13 @@ BOOL astarInitialise(void)
ClearAstarNodes();
#else
// Create the two hash tables
apsOpen = MALLOC(sizeof(FP_NODE *) * FPATH_TABLESIZE);
apsOpen = malloc(sizeof(FP_NODE *) * FPATH_TABLESIZE);
if (!apsOpen)
{
return FALSE;
}
memset(apsOpen, 0, sizeof(FP_NODE *) * FPATH_TABLESIZE);
apsClosed = MALLOC(sizeof(FP_NODE *) * FPATH_TABLESIZE);
apsClosed = malloc(sizeof(FP_NODE *) * FPATH_TABLESIZE);
if (!apsClosed)
{
return FALSE;
@ -174,10 +174,10 @@ void fpathShutDown(void)
{
HEAP_DESTROY(psFPNodeHeap);
#if OPEN_LIST == 2
FREE(apsNodes);
free(apsNodes);
#else
FREE(apsOpen);
FREE(apsClosed);
free(apsOpen);
free(apsClosed);
#endif
}

View File

@ -101,7 +101,7 @@ void snapInitVars(void)
void AllocateSnapBuffer(CURSORSNAP *SnapBuffer,UWORD MaxSnaps)
{
SnapBuffer->SnapCoords = (SNAPCOORD*)MALLOC(sizeof(CURSORSNAP)*MaxSnaps);
SnapBuffer->SnapCoords = (SNAPCOORD*)malloc(sizeof(CURSORSNAP)*MaxSnaps);
SnapBuffer->MaxSnaps = MaxSnaps;
SnapBuffer->NumSnaps = 0;
SnapBuffer->CurrentSnap = 0;
@ -112,7 +112,7 @@ void AllocateSnapBuffer(CURSORSNAP *SnapBuffer,UWORD MaxSnaps)
void ReleaseSnapBuffer(CURSORSNAP *SnapBuffer)
{
FREE(SnapBuffer->SnapCoords);
free(SnapBuffer->SnapCoords);
}

View File

@ -741,7 +741,7 @@ static BOOL dataIMDBufferLoad(char *pBuffer, UDWORD size, void **ppData)
BOOL dataIMGPAGELoad(char *pBuffer, UDWORD size, void **ppData)
{
iTexture *psSprite = (iTexture*) MALLOC(sizeof(iTexture));
iTexture *psSprite = (iTexture*) malloc(sizeof(iTexture));
if (!psSprite) {
return FALSE;
}
@ -893,16 +893,16 @@ static BOOL bufferTexPageLoad(char *pBuffer, UDWORD size, void **ppData)
debug(LOG_TEXTURE, "bufferTexPageLoad: adding page %s with texture %s", texpage, texfile);
NewTexturePage = (TEXTUREPAGE*)MALLOC(sizeof(TEXTUREPAGE));
NewTexturePage = (TEXTUREPAGE*)malloc(sizeof(TEXTUREPAGE));
if (!NewTexturePage) return FALSE;
NewTexturePage->Texture=NULL;
NewTexturePage->Palette=NULL;
psPal = (iPalette*)MALLOC(sizeof(iPalette));
psPal = (iPalette*)malloc(sizeof(iPalette));
if (!psPal) return FALSE;
psSprite = (iTexture*)MALLOC(sizeof(iTexture));
psSprite = (iTexture*)malloc(sizeof(iTexture));
if (!psSprite)
{
return FALSE;
@ -937,7 +937,7 @@ static void dataISpriteRelease(void *pData)
free(psSprite->bmp);
psSprite->bmp = NULL;
}
FREE(psSprite);
free(psSprite);
psSprite = NULL;
}
}
@ -956,9 +956,9 @@ static void dataTexPageRelease(void *pData)
dataISpriteRelease(Tpage->Texture);
}
if (Tpage->Palette != NULL)
FREE(Tpage->Palette);
free(Tpage->Palette);
FREE(Tpage);
free(Tpage);
}

View File

@ -440,7 +440,7 @@ void droidRelease(DROID *psDroid)
}
}
}
//FREE(psDroid->pName);
//free(psDroid->pName);
// leave the current formation if any
if (psDroid->sMove.psFormation)
@ -3139,7 +3139,7 @@ BOOL loadDroidTemplates(const char *pDroidData, UDWORD bufferSize)
pDroidData = strchr(pDroidData,'\n') + 1;
pDroidDesign++;
}
// FREE(pStartDroidData);
// free(pStartDroidData);
@ -3437,7 +3437,7 @@ BOOL loadDroidWeapons(const char *pWeaponData, UDWORD bufferSize)
}
// FREE(pStartWeaponData);
// free(pStartWeaponData);
return TRUE;
}

View File

@ -103,7 +103,7 @@ static void rotBox(PASTE_BOX *psBox);
char aType[255], *pCurr;
// Allocate an array to store the type mapping
aDefaultType = MALLOC(sizeof(TERRAIN_TYPE) * maxTexTile);
aDefaultType = malloc(sizeof(TERRAIN_TYPE) * maxTexTile);
if (!aDefaultType)
{
DBERROR(("Out of memory"));
@ -124,7 +124,7 @@ static void rotBox(PASTE_BOX *psBox);
if (texNum >= maxTexTile)
{
DBERROR(("texture number out of range in typemap.txt"));
FREE(pFileData);
free(pFileData);
return FALSE;
}
if (strcmp(aType, "grass") == 0)
@ -153,12 +153,12 @@ static void rotBox(PASTE_BOX *psBox);
if (pCurr - (char *)pFileData > (SDWORD)fileSize)
{
DBERROR(("Unexpected EOF in typemap.txt"));
FREE(pFileData);
free(pFileData);
return FALSE;
}
}
FREE(pFileData);
free(pFileData);
return TRUE;
}*/
@ -188,14 +188,14 @@ void ed2dShutDown(void)
{
if (sPasteBox.psTiles != NULL)
{
FREE(sPasteBox.psTiles);
free(sPasteBox.psTiles);
}
if (sUndoBox.psTiles != NULL)
{
FREE(sUndoBox.psTiles);
free(sUndoBox.psTiles);
}
// FREE(aDefaultType);
// free(aDefaultType);
}
@ -265,7 +265,7 @@ BOOL ed2dProcessInput(void)
{
if (sPasteBox.psTiles != NULL)
{
FREE(sPasteBox.psTiles);
free(sPasteBox.psTiles);
}
if (getBox(&sPasteBox, selSX,selSY, selEX-selSX+1,selEY-selSY+1))
{
@ -406,11 +406,11 @@ BOOL ed2dProcessInput(void)
/* Free any old undo and paste buffer */
if (sPasteBox.psTiles != NULL)
{
FREE(sPasteBox.psTiles);
free(sPasteBox.psTiles);
}
if (sUndoBox.psTiles != NULL)
{
FREE(sUndoBox.psTiles);
free(sUndoBox.psTiles);
}
/* Get the paste and undo boxes */
@ -421,7 +421,7 @@ BOOL ed2dProcessInput(void)
}
if (!getBox(&sUndoBox, selSX,selSY, selEX - selSX + 1, selEY - selSY + 1))
{
FREE(sPasteBox.psTiles);
free(sPasteBox.psTiles);
sPasteBox.psTiles = NULL;
mState = MS_GAME;
break;
@ -453,7 +453,7 @@ BOOL ed2dProcessInput(void)
/* Free the old undo data */
if (sUndoBox.psTiles != NULL)
{
FREE(sUndoBox.psTiles);
free(sUndoBox.psTiles);
}
/* Get the new undo data */
if (!getBox(&sUndoBox, selSX, selSY, sPasteBox.width,sPasteBox.height))
@ -528,7 +528,7 @@ BOOL ed2dProcessInput(void)
sGrabBox.width,sGrabBox.height);
flipBoxX(&sGrabBox);
putBox(&sGrabBox, selSX,selSY);
FREE(sGrabBox.psTiles);
free(sGrabBox.psTiles);
}
/* Flip on Y axis */
if (keyPressed(KEY_Y) &&
@ -538,7 +538,7 @@ BOOL ed2dProcessInput(void)
sGrabBox.width,sGrabBox.height);
flipBoxY(&sGrabBox);
putBox(&sGrabBox, selSX,selSY);
FREE(sGrabBox.psTiles);
free(sGrabBox.psTiles);
}
/* Rotate */
if (keyPressed(KEY_Z) &&
@ -549,7 +549,7 @@ BOOL ed2dProcessInput(void)
sGrabBox.width,sGrabBox.height);
rotBox(&sGrabBox);
putBox(&sGrabBox, selSX,selSY);
FREE(sGrabBox.psTiles);
free(sGrabBox.psTiles);
}
}
else if (mState == MS_PASTE)
@ -786,7 +786,7 @@ static BOOL getBox(PASTE_BOX *psBox, UDWORD x, UDWORD y, UDWORD width, UDWORD he
psBox->y = y;
psBox->width = width;
psBox->height = height;
psBox->psTiles = (MAPTILE *)MALLOC(sizeof(MAPTILE)*
psBox->psTiles = (MAPTILE *)malloc(sizeof(MAPTILE)*
psBox->width * psBox->height);
if (psBox->psTiles == NULL)
{
@ -839,7 +839,7 @@ static void flipBoxX(PASTE_BOX *psBox)
UDWORD tex1,tex2;
/* Allocate a buffer for the flipped version */
psNew = (MAPTILE *)MALLOC(sizeof(MAPTILE) * psBox->width * psBox->height);
psNew = (MAPTILE *)malloc(sizeof(MAPTILE) * psBox->width * psBox->height);
if (psNew == NULL)
{
debug( LOG_ERROR, "Out of memory, couldn't do flip\n" );
@ -876,7 +876,7 @@ static void flipBoxX(PASTE_BOX *psBox)
}
}
FREE(psBox->psTiles);
free(psBox->psTiles);
psBox->psTiles = psNew;
}
@ -889,7 +889,7 @@ static void flipBoxY(PASTE_BOX *psBox)
UDWORD tex1,tex2;
/* Allocate a buffer for the flipped version */
psNew = (MAPTILE *)MALLOC(sizeof(MAPTILE) * psBox->width * psBox->height);
psNew = (MAPTILE *)malloc(sizeof(MAPTILE) * psBox->width * psBox->height);
if (psNew == NULL)
{
debug( LOG_ERROR, "Out of memory, couldn't do flip\n" );
@ -926,7 +926,7 @@ static void flipBoxY(PASTE_BOX *psBox)
}
}
FREE(psBox->psTiles);
free(psBox->psTiles);
psBox->psTiles = psNew;
}
@ -941,7 +941,7 @@ static void rotBox(PASTE_BOX *psBox)
MAPTILE *psNew, *psSrc, *psDest;
/* Allocate the new tile buffer */
psNew = (MAPTILE *)MALLOC(sizeof(MAPTILE) * psBox->width * psBox->height);
psNew = (MAPTILE *)malloc(sizeof(MAPTILE) * psBox->width * psBox->height);
if (psNew == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -965,7 +965,7 @@ static void rotBox(PASTE_BOX *psBox)
}
/* Store the new tiles into the box */
FREE(psBox->psTiles);
free(psBox->psTiles);
psBox->psTiles = psNew;
x = psBox->width;
psBox->width = psBox->height;
@ -1007,7 +1007,7 @@ BOOL ed2dLoadMapFile(void)
/* Load the data into the map -
don't check the return code as we do the same thing either way */
(void)mapLoad(pFileData, fileSize);
FREE(pFileData);
free(pFileData);
/* Start the game clock */
gameTimeStart();

View File

@ -2905,7 +2905,7 @@ iIMDShape *psOrig;
fileSize = ( sizeof(struct _fx_save_header) + ( fxEntries*sizeof(struct _effect_def) ) );
/* Try and allocate it - freed up in same function */
pFileData = (char*)MALLOC(fileSize);
pFileData = (char*)malloc(fileSize);
/* Did we get it? */
if(!pFileData)
@ -2998,7 +2998,7 @@ iIMDShape *psOrig;
/* And free up the memory we used */
if (pFileData != NULL)
{
FREE(pFileData);
free(pFileData);
}
/* Everything is just fine! */
return TRUE;

View File

@ -78,7 +78,7 @@ BOOL waterOnMap(void)
//this function just allocates the memory now for MaxMapWidth, MaxMapHeight
BOOL environInit( void )
{
pEnvironData = (ENVIRON_DATA*)MALLOC(sizeof(struct environ_data) * MAP_MAXWIDTH * MAP_MAXHEIGHT);
pEnvironData = (ENVIRON_DATA*)malloc(sizeof(struct environ_data) * MAP_MAXWIDTH * MAP_MAXHEIGHT);
if(!pEnvironData)
{
debug( LOG_ERROR, "Can't get memory for the environment data" );
@ -372,6 +372,6 @@ void environShutDown( void )
{
if(pEnvironData)
{
FREE(pEnvironData);
free(pEnvironData);
}
}

View File

@ -173,7 +173,7 @@ BOOL loadFeatureStats(char *pFeatureData, UDWORD bufferSize)
numFeatureStats = numCR(pFeatureData, bufferSize);
asFeatureStats = (FEATURE_STATS *)MALLOC(sizeof(FEATURE_STATS)*
asFeatureStats = (FEATURE_STATS *)malloc(sizeof(FEATURE_STATS)*
numFeatureStats);
if (asFeatureStats == NULL)
@ -259,13 +259,13 @@ BOOL loadFeatureStats(char *pFeatureData, UDWORD bufferSize)
psFeature++;
}
// FREE(pData);
// free(pData);
return TRUE;
/* Allocate the stats Array */
/* numFeatureStats = 19;
asFeatureStats = (FEATURE_STATS *)MALLOC(sizeof(FEATURE_STATS) * numFeatureStats);
asFeatureStats = (FEATURE_STATS *)malloc(sizeof(FEATURE_STATS) * numFeatureStats);
if (!asFeatureStats)
{
DBERROR(("Out of memory"));
@ -626,13 +626,13 @@ void featureStatsShutDown(void)
for(inc=0; inc < numFeatureStats; inc++, psFeature++)
{
FREE(psFeature->pName);
free(psFeature->pName);
}
#endif
if(numFeatureStats)
{
FREE(asFeatureStats);
free(asFeatureStats);
}
}

View File

@ -117,7 +117,7 @@ BOOL loadFunctionStats(char *pFunctionData, UDWORD bufferSize)
totalFunctions = numCR(pFunctionData, bufferSize);
//allocate storage for the Function pointer array
asFunctions = (FUNCTION**) MALLOC(totalFunctions*sizeof(FUNCTION*));
asFunctions = (FUNCTION**) malloc(totalFunctions*sizeof(FUNCTION*));
if (!asFunctions)
{
debug( LOG_ERROR, "Out of memory" );
@ -155,7 +155,7 @@ BOOL loadFunctionStats(char *pFunctionData, UDWORD bufferSize)
//create Upgrade arrays
//for (player = 0; player < MAX_PLAYERS; player++)
//{
/*apProductionUpgrades[player] = (FUNCTION_UPGRADE *) MALLOC(numProductionUpgrades *
/*apProductionUpgrades[player] = (FUNCTION_UPGRADE *) malloc(numProductionUpgrades *
sizeof(FUNCTION_UPGRADE));
if (!apProductionUpgrades[player])
{
@ -163,7 +163,7 @@ BOOL loadFunctionStats(char *pFunctionData, UDWORD bufferSize)
return FALSE;
}
apResearchUpgrades[player] = (FUNCTION_UPGRADE *) MALLOC(numResearchUpgrades *
apResearchUpgrades[player] = (FUNCTION_UPGRADE *) malloc(numResearchUpgrades *
sizeof(FUNCTION_UPGRADE));
if (!apResearchUpgrades[player])
{
@ -171,7 +171,7 @@ BOOL loadFunctionStats(char *pFunctionData, UDWORD bufferSize)
return FALSE;
}*/
/*apBodyUpgrades[player] = (FUNCTION_UPGRADE *) MALLOC(numBodyUpgrades *
/*apBodyUpgrades[player] = (FUNCTION_UPGRADE *) malloc(numBodyUpgrades *
sizeof(FUNCTION_UPGRADE));
if (!apBodyUpgrades[player])
{
@ -179,7 +179,7 @@ BOOL loadFunctionStats(char *pFunctionData, UDWORD bufferSize)
return FALSE;
}*/
/*apArmourUpgrades[player] = (FUNCTION_UPGRADE *) MALLOC(numArmourUpgrades *
/*apArmourUpgrades[player] = (FUNCTION_UPGRADE *) malloc(numArmourUpgrades *
sizeof(FUNCTION_UPGRADE));
if (!apArmourUpgrades[player])
{
@ -187,7 +187,7 @@ BOOL loadFunctionStats(char *pFunctionData, UDWORD bufferSize)
return FALSE;
}*/
/*apRepairUpgrades[player] = (FUNCTION_UPGRADE *) MALLOC(numRepairUpgrades *
/*apRepairUpgrades[player] = (FUNCTION_UPGRADE *) malloc(numRepairUpgrades *
sizeof(FUNCTION_UPGRADE));
if (!apRepairUpgrades[player])
{
@ -195,14 +195,14 @@ BOOL loadFunctionStats(char *pFunctionData, UDWORD bufferSize)
return FALSE;
}*/
/*apResistanceUpgrades[player] = (FUNCTION_UPGRADE *) MALLOC(numResistanceUpgrades *
/*apResistanceUpgrades[player] = (FUNCTION_UPGRADE *) malloc(numResistanceUpgrades *
sizeof(FUNCTION_UPGRADE));
if (!apResistanceUpgrades[player])
{
DBERROR(("Out of memory"));
return FALSE;
}*/
/*apWeaponUpgrades[player] = (FUNCTION_UPGRADE *) MALLOC(numWeaponUpgrades *
/*apWeaponUpgrades[player] = (FUNCTION_UPGRADE *) malloc(numWeaponUpgrades *
sizeof(FUNCTION_UPGRADE));
if (!apWeaponUpgrades[player])
{
@ -301,7 +301,7 @@ BOOL loadFunctionStats(char *pFunctionData, UDWORD bufferSize)
// Allocate storage for the name
BOOL storeName(FUNCTION* pFunction, char* pNameToStore)
{
pFunction->pName = (char *)MALLOC(strlen(pNameToStore)+1);
pFunction->pName = (char *)malloc(strlen(pNameToStore)+1);
if (pFunction->pName == NULL)
{
debug( LOG_ERROR, "Function Name - Out of memory" );
@ -318,7 +318,7 @@ BOOL storeName(FUNCTION* pFunction, char* pNameToStore)
char functionName[50];
//allocate storage
psFunction = (FUNCTION *)MALLOC(sizeof(FUNCTION));
psFunction = (FUNCTION *)malloc(sizeof(FUNCTION));
if (psFunction == NULL)
{
DBERROR(("Function - Out of memory"));
@ -366,7 +366,7 @@ BOOL loadProduction(char *pData)
//PROPULSION_TYPES* pPropulsionType;
//allocate storage
psFunction = (PRODUCTION_FUNCTION *)MALLOC(sizeof(PRODUCTION_FUNCTION));
psFunction = (PRODUCTION_FUNCTION *)malloc(sizeof(PRODUCTION_FUNCTION));
if (psFunction == NULL)
{
debug( LOG_ERROR, "Production Function - Out of memory" );
@ -454,7 +454,7 @@ BOOL loadProductionUpgradeFunction(char *pData)
UDWORD outputModifier;
//allocate storage
psFunction = (PRODUCTION_UPGRADE_FUNCTION *)MALLOC(sizeof
psFunction = (PRODUCTION_UPGRADE_FUNCTION *)malloc(sizeof
(PRODUCTION_UPGRADE_FUNCTION));
if (psFunction == NULL)
{
@ -520,7 +520,7 @@ BOOL loadResearchFunction(char *pData)
char functionName[MAX_NAME_SIZE];
//allocate storage
psFunction = (RESEARCH_FUNCTION *)MALLOC(sizeof(RESEARCH_FUNCTION));
psFunction = (RESEARCH_FUNCTION *)malloc(sizeof(RESEARCH_FUNCTION));
if (psFunction == NULL)
{
debug( LOG_ERROR, "Research Function - Out of memory" );
@ -554,7 +554,7 @@ BOOL loadReArmFunction(char *pData)
char functionName[MAX_NAME_SIZE];
//allocate storage
psFunction = (REARM_FUNCTION *)MALLOC(sizeof(REARM_FUNCTION));
psFunction = (REARM_FUNCTION *)malloc(sizeof(REARM_FUNCTION));
if (psFunction == NULL)
{
debug( LOG_ERROR, "ReArm Function - Out of memory" );
@ -661,7 +661,7 @@ BOOL loadUpgradeFunction(char *pData, UBYTE type)
UPGRADE_FUNCTION *psFunction;
//allocate storage
psFunction = (UPGRADE_FUNCTION *)MALLOC(sizeof(UPGRADE_FUNCTION));
psFunction = (UPGRADE_FUNCTION *)malloc(sizeof(UPGRADE_FUNCTION));
if (psFunction == NULL)
{
debug( LOG_ERROR, "Upgrade Function - Out of memory" );
@ -706,7 +706,7 @@ BOOL loadDroidBodyUpgradeFunction(char *pData)
body, droid, cyborg;
//allocate storage
psFunction = (DROIDBODY_UPGRADE_FUNCTION *)MALLOC(
psFunction = (DROIDBODY_UPGRADE_FUNCTION *)malloc(
sizeof(DROIDBODY_UPGRADE_FUNCTION));
if (psFunction == NULL)
{
@ -773,7 +773,7 @@ BOOL loadDroidSensorUpgradeFunction(char *pData)
UDWORD modifier, range;
//allocate storage
psFunction = (DROIDSENSOR_UPGRADE_FUNCTION *)MALLOC(
psFunction = (DROIDSENSOR_UPGRADE_FUNCTION *)malloc(
sizeof(DROIDSENSOR_UPGRADE_FUNCTION));
if (psFunction == NULL)
{
@ -822,7 +822,7 @@ BOOL loadWeaponUpgradeFunction(char *pData)
radiusDamage, incenDamage, radiusHit;
//allocate storage
psFunction = (WEAPON_UPGRADE_FUNCTION *)MALLOC(sizeof
psFunction = (WEAPON_UPGRADE_FUNCTION *)malloc(sizeof
(WEAPON_UPGRADE_FUNCTION));
if (psFunction == NULL)
{
@ -893,7 +893,7 @@ BOOL loadStructureUpgradeFunction(char *pData)
UDWORD armour, body, resistance;
//allocate storage
psFunction = (STRUCTURE_UPGRADE_FUNCTION *)MALLOC(sizeof
psFunction = (STRUCTURE_UPGRADE_FUNCTION *)malloc(sizeof
(STRUCTURE_UPGRADE_FUNCTION));
if (psFunction == NULL)
{
@ -944,7 +944,7 @@ BOOL loadWallDefenceUpgradeFunction(char *pData)
UDWORD armour, body;
//allocate storage
psFunction = (WALLDEFENCE_UPGRADE_FUNCTION *)MALLOC(sizeof
psFunction = (WALLDEFENCE_UPGRADE_FUNCTION *)malloc(sizeof
(WALLDEFENCE_UPGRADE_FUNCTION));
if (psFunction == NULL)
{
@ -992,7 +992,7 @@ BOOL loadWallDefenceUpgradeFunction(char *pData)
char functionName[MAX_NAME_SIZE];
//allocate storage
psFunction = (BODY_UPGRADE_FUNCTION *)MALLOC(sizeof
psFunction = (BODY_UPGRADE_FUNCTION *)malloc(sizeof
(BODY_UPGRADE_FUNCTION));
if (psFunction == NULL)
{
@ -1028,7 +1028,7 @@ BOOL loadWallDefenceUpgradeFunction(char *pData)
char functionName[MAX_NAME_SIZE];
//allocate storage
psFunction = (RADAR_MAP_FUNCTION *)MALLOC(sizeof
psFunction = (RADAR_MAP_FUNCTION *)malloc(sizeof
(RADAR_MAP_FUNCTION));
if (psFunction == NULL)
{
@ -1062,7 +1062,7 @@ BOOL loadPowerGenFunction(char *pData)
char functionName[MAX_NAME_SIZE];
//allocate storage
psFunction = (POWER_GEN_FUNCTION *)MALLOC(sizeof
psFunction = (POWER_GEN_FUNCTION *)malloc(sizeof
(POWER_GEN_FUNCTION));
if (psFunction == NULL)
{
@ -1107,7 +1107,7 @@ BOOL loadResourceFunction(char *pData)
char functionName[MAX_NAME_SIZE];
//allocate storage
psFunction = (RESOURCE_FUNCTION *)MALLOC(sizeof
psFunction = (RESOURCE_FUNCTION *)malloc(sizeof
(RESOURCE_FUNCTION));
if (psFunction == NULL)
{
@ -1142,7 +1142,7 @@ BOOL loadResourceFunction(char *pData)
char functionName[MAX_NAME_SIZE];
//allocate storage
psFunction = (POWER_REG_FUNCTION *)MALLOC(sizeof
psFunction = (POWER_REG_FUNCTION *)malloc(sizeof
(POWER_REG_FUNCTION));
if (psFunction == NULL)
{
@ -1176,7 +1176,7 @@ BOOL loadResourceFunction(char *pData)
char functionName[MAX_NAME_SIZE];
//allocate storage
psFunction = (POWER_RELAY_FUNCTION *)MALLOC(sizeof
psFunction = (POWER_RELAY_FUNCTION *)malloc(sizeof
(POWER_RELAY_FUNCTION));
if (psFunction == NULL)
{
@ -1210,7 +1210,7 @@ BOOL loadRepairDroidFunction(char *pData)
char functionName[MAX_NAME_SIZE];
//allocate storage
psFunction = (REPAIR_DROID_FUNCTION *)MALLOC(sizeof
psFunction = (REPAIR_DROID_FUNCTION *)malloc(sizeof
(REPAIR_DROID_FUNCTION));
if (psFunction == NULL)
{
@ -1255,7 +1255,7 @@ BOOL loadRepairDroidFunction(char *pData)
ECM_STATS* pECMType;
//allocate storage
psFunction = (DEFENSIVE_STRUCTURE_FUNCTION *)MALLOC(
psFunction = (DEFENSIVE_STRUCTURE_FUNCTION *)malloc(
sizeof(DEFENSIVE_STRUCTURE_FUNCTION));
if (psFunction == NULL)
{
@ -1326,7 +1326,7 @@ BOOL loadRepairDroidFunction(char *pData)
char functionName[MAX_NAME_SIZE];
//allocate storage
psFunction = (HQ_FUNCTION *)MALLOC(sizeof(HQ_FUNCTION));
psFunction = (HQ_FUNCTION *)malloc(sizeof(HQ_FUNCTION));
if (psFunction == NULL)
{
DBERROR(("HQ Function - Out of memory"));
@ -1362,7 +1362,7 @@ BOOL loadRepairDroidFunction(char *pData)
// ARMOUR_STATS* pArmourType;
//allocate storage
psFunction = (ARMOUR_UPGRADE_FUNCTION *)MALLOC(sizeof(ARMOUR_UPGRADE_FUNCTION));
psFunction = (ARMOUR_UPGRADE_FUNCTION *)malloc(sizeof(ARMOUR_UPGRADE_FUNCTION));
if (psFunction == NULL)
{
DBERROR(("Armour Upgrade Function - Out of memory"));
@ -1421,7 +1421,7 @@ BOOL loadRepairDroidFunction(char *pData)
REPAIR_STATS* pRepairType;
//allocate storage
psFunction = (REPAIR_UPGRADE_FUNCTION *)MALLOC(sizeof(REPAIR_UPGRADE_FUNCTION));
psFunction = (REPAIR_UPGRADE_FUNCTION *)malloc(sizeof(REPAIR_UPGRADE_FUNCTION));
if (psFunction == NULL)
{
DBERROR(("Repair Upgrade Function - Out of memory"));
@ -1485,7 +1485,7 @@ BOOL loadRepairDroidFunction(char *pData)
char functionName[MAX_NAME_SIZE];
//allocate storage
psFunction = (RESISTANCE_UPGRADE_FUNCTION *)MALLOC(sizeof
psFunction = (RESISTANCE_UPGRADE_FUNCTION *)malloc(sizeof
(RESISTANCE_UPGRADE_FUNCTION));
if (psFunction == NULL)
{
@ -1527,7 +1527,7 @@ BOOL loadWallFunction(char *pData)
// STRUCTURE_STATS *pStructStat;
//allocate storage
psFunction = (WALL_FUNCTION *)MALLOC(sizeof(WALL_FUNCTION));
psFunction = (WALL_FUNCTION *)malloc(sizeof(WALL_FUNCTION));
if (psFunction == NULL)
{
debug( LOG_ERROR, "Wall Function - Out of memory" );
@ -1555,7 +1555,7 @@ BOOL loadWallFunction(char *pData)
//store the structure name - cannot set the stat pointer here because structures
//haven't been loaded in yet!
/*psFunction->pStructName = (char *)MALLOC(strlen(structureName)+1);
/*psFunction->pStructName = (char *)malloc(strlen(structureName)+1);
if (psFunction->pStructName == NULL)
{
DBERROR(("Function Name - Out of memory"));
@ -2230,30 +2230,30 @@ BOOL FunctionShutDown(void)
for (inc=0; inc < numFunctions; inc++)
{
pFunction = *asFunctions;
FREE(pFunction->pName);
free(pFunction->pName);
//#ifndef RESOURCE_NAMES
#if !defined (RESOURCE_NAMES) && !defined(STORE_RESOURCE_ID)
if (pFunction->type == WALL_TYPE)
{
FREE(((WALL_FUNCTION *)pFunction)->pStructName);
free(((WALL_FUNCTION *)pFunction)->pStructName);
}
#endif
FREE (pFunction);
free(pFunction);
asFunctions++;
}
FREE (pStartList);
free(pStartList);
//free the Upgrade lists
/*for (player=0; player < MAX_PLAYERS; player++)
{
FREE(apProductionUpgrades[player]);
//FREE(apBodyUpgrades[player]);
//FREE(apRepairUpgrades[player]);
//FREE(apResistanceUpgrades[player]);
FREE(apResearchUpgrades[player]);
//FREE(apArmourUpgrades[player]);
//FREE(apWeaponUpgrades[player]);
free(apProductionUpgrades[player]);
//free(apBodyUpgrades[player]);
//free(apRepairUpgrades[player]);
//free(apResistanceUpgrades[player]);
free(apResearchUpgrades[player]);
//free(apArmourUpgrades[player]);
//free(apWeaponUpgrades[player]);
}*/
return TRUE;
}

View File

@ -1525,12 +1525,12 @@ BOOL loadGame(char *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSaveGa
// droidTemplateShutDown();
if (psMapTiles)
{
// FREE(psMapTiles);
// free(psMapTiles);
// mapFreeTilesAndStrips();
}
if (aMapLinePoints)
{
FREE(aMapLinePoints);
free(aMapLinePoints);
}
//clear all the messages?
releaseAllProxDisp();
@ -2822,12 +2822,12 @@ error:
droidTemplateShutDown();
if (psMapTiles)
{
// FREE(psMapTiles);
// free(psMapTiles);
// mapFreeTilesAndStrips();
}
if (aMapLinePoints)
{
FREE(aMapLinePoints);
free(aMapLinePoints);
}
psMapTiles = NULL;
aMapLinePoints = NULL;
@ -2842,7 +2842,7 @@ error:
return FALSE;
}
FREE(pFileData);*/
free(pFileData);*/
/* Start the game clock */
gameTimeStart();
@ -3210,7 +3210,7 @@ BOOL writeMapFile(char *pFileName)
status = saveFile(pFileName, pFileData, fileSize);
}
if (pFileData != NULL) {
FREE(pFileData);
free(pFileData);
}
return status;
}
@ -4106,7 +4106,7 @@ BOOL writeGameFile(char *pFileName, SDWORD saveType)
/* Allocate the data buffer */
fileSize = GAME_HEADER_SIZE + sizeof(SAVE_GAME);
pFileData = (char*)MALLOC(fileSize);
pFileData = (char*)malloc(fileSize);
if (pFileData == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -4390,14 +4390,14 @@ BOOL writeGameFile(char *pFileName, SDWORD saveType)
/* Write the data to the file */
if (pFileData != NULL) {
status = saveFile(pFileName, pFileData, fileSize);
FREE(pFileData);
free(pFileData);
return status;
}
error:
if (pFileData != NULL)
{
FREE(pFileData);
free(pFileData);
}
return FALSE;
}
@ -4700,7 +4700,7 @@ static DROID* buildDroidFromSaveDroidV11(SAVE_DROID_V11* psSaveDroid)
{
ASSERT(FALSE, "This component does not exist : %s", psSaveDroid->asWeaps[i].name );
return NULL;
}
}
psTemplate->asWeaps[i] = weapon;
}
@ -4815,7 +4815,7 @@ static DROID* buildDroidFromSaveDroidV19(SAVE_DROID_V18* psSaveDroid, UDWORD ver
{
ASSERT(FALSE, "This component does not exist : %s", psSaveDroid->asWeaps[i].name );
return NULL;
}
}
psTemplate->asWeaps[i] = weapon;
}
}
@ -5069,7 +5069,7 @@ static DROID* buildDroidFromSaveDroid(SAVE_DROID* psSaveDroid, UDWORD version)
{
ASSERT(FALSE, "This component does not exist : %s", psSaveDroid->asWeaps[i].name );
return NULL;
}
}
psTemplate->asWeaps[i] = weapon;
}
}
@ -6302,7 +6302,7 @@ BOOL writeDroidFile(char *pFileName, DROID **ppsCurrentDroidLists)
/* Allocate the data buffer */
fileSize = DROID_HEADER_SIZE + totalDroids*sizeof(SAVE_DROID);
pFileData = (char*)MALLOC(fileSize);
pFileData = (char*)malloc(fileSize);
if (pFileData == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -6361,7 +6361,7 @@ BOOL writeDroidFile(char *pFileName, DROID **ppsCurrentDroidLists)
/* Write the data to the file */
if (pFileData != NULL) {
status = saveFile(pFileName, pFileData, fileSize);
FREE(pFileData);
free(pFileData);
return status;
}
return FALSE;
@ -7612,7 +7612,7 @@ BOOL writeStructFile(char *pFileName)
/* Allocate the data buffer */
fileSize = STRUCT_HEADER_SIZE + totalStructs*sizeof(SAVE_STRUCTURE);
pFileData = (char*)MALLOC(fileSize);
pFileData = (char*)malloc(fileSize);
if (pFileData == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -7857,7 +7857,7 @@ BOOL writeStructFile(char *pFileName)
/* Write the data to the file */
if (pFileData != NULL) {
status = saveFile(pFileName, pFileData, fileSize);
FREE(pFileData);
free(pFileData);
return status;
}
return FALSE;
@ -8266,7 +8266,7 @@ BOOL writeFeatureFile(char *pFileName)
/* Allocate the data buffer */
fileSize = FEATURE_HEADER_SIZE + totalFeatures * sizeof(SAVE_FEATURE);
pFileData = (char*)MALLOC(fileSize);
pFileData = (char*)malloc(fileSize);
if (pFileData == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -8333,7 +8333,7 @@ BOOL writeFeatureFile(char *pFileName)
/* Write the data to the file */
if (pFileData != NULL) {
status = saveFile(pFileName, pFileData, fileSize);
FREE(pFileData);
free(pFileData);
return status;
}
return FALSE;
@ -8899,7 +8899,7 @@ BOOL writeTemplateFile(char *pFileName)
/* Allocate the data buffer */
fileSize = TEMPLATE_HEADER_SIZE + totalTemplates*sizeof(SAVE_TEMPLATE);
pFileData = (char*)MALLOC(fileSize);
pFileData = (char*)malloc(fileSize);
if (pFileData == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -8983,7 +8983,7 @@ BOOL writeTemplateFile(char *pFileName)
/* Write the data to the file */
if (pFileData != NULL) {
status = saveFile(pFileName, pFileData, fileSize);
FREE(pFileData);
free(pFileData);
return status;
}
return FALSE;
@ -9073,7 +9073,7 @@ static BOOL writeTerrainTypeMapFile(char *pFileName)
// Calculate the file size
fileSize = TILETYPE_HEADER_SIZE + sizeof(UWORD) * MAX_TILE_TEXTURES;
pFileData = (char*)MALLOC(fileSize);
pFileData = (char*)malloc(fileSize);
if (!pFileData)
{
debug( LOG_ERROR, "writeTerrainTypeMapFile: Out of memory" );
@ -9106,7 +9106,7 @@ static BOOL writeTerrainTypeMapFile(char *pFileName)
{
return FALSE;
}
FREE(pFileData);
free(pFileData);
return TRUE;
}
@ -9301,7 +9301,7 @@ static BOOL writeCompListFile(char *pFileName)
numPropulsionStats + numSensorStats + numRepairStats + numBrainStats) * MAX_PLAYERS;
fileSize = COMPLIST_HEADER_SIZE + (sizeof(SAVE_COMPLIST) * totalComp);
//allocate the buffer space
pFileData = (char*)MALLOC(fileSize);
pFileData = (char*)malloc(fileSize);
if (!pFileData)
{
debug( LOG_ERROR, "writeCompListFile: Out of memory" );
@ -9421,7 +9421,7 @@ static BOOL writeCompListFile(char *pFileName)
{
return FALSE;
}
FREE(pFileData);
free(pFileData);
return TRUE;
}
@ -9613,7 +9613,7 @@ static BOOL writeStructTypeListFile(char *pFileName)
numStructureStats * MAX_PLAYERS);
//allocate the buffer space
pFileData = (char*)MALLOC(fileSize);
pFileData = (char*)malloc(fileSize);
if (!pFileData)
{
debug( LOG_ERROR, "writeStructTypeListFile: Out of memory" );
@ -9654,7 +9654,7 @@ static BOOL writeStructTypeListFile(char *pFileName)
{
return FALSE;
}
FREE(pFileData);
free(pFileData);
return TRUE;
}
@ -9890,7 +9890,7 @@ static BOOL writeResearchFile(char *pFileName)
numResearch);
//allocate the buffer space
pFileData = (char*)MALLOC(fileSize);
pFileData = (char*)malloc(fileSize);
if (!pFileData)
{
debug( LOG_ERROR, "writeResearchFile: Out of memory" );
@ -9936,7 +9936,7 @@ static BOOL writeResearchFile(char *pFileName)
{
return FALSE;
}
FREE(pFileData);
free(pFileData);
return TRUE;
}
@ -10115,7 +10115,7 @@ static BOOL writeMessageFile(char *pFileName)
//allocate the buffer space
pFileData = (char*)MALLOC(fileSize);
pFileData = (char*)malloc(fileSize);
if (!pFileData)
{
debug( LOG_ERROR, "writeMessageFile: Out of memory" );
@ -10195,7 +10195,7 @@ static BOOL writeMessageFile(char *pFileName)
{
return FALSE;
}
FREE(pFileData);
free(pFileData);
return TRUE;
}
@ -10313,7 +10313,7 @@ static BOOL writeProximityFile(char *pFileName)
//allocate the buffer space
pFileData = (char*)MALLOC(fileSize);
pFileData = (char*)malloc(fileSize);
if (!pFileData)
{
debug( LOG_ERROR, "writeProximityFile: Out of memory" );
@ -10376,7 +10376,7 @@ static BOOL writeProximityFile(char *pFileName)
{
return FALSE;
}
FREE(pFileData);
free(pFileData);
return TRUE;
}
@ -10612,7 +10612,7 @@ static BOOL writeFlagFile(char *pFileName)
//allocate the buffer space
pFileData = (char*)MALLOC(fileSize);
pFileData = (char*)malloc(fileSize);
if (!pFileData)
{
debug( LOG_ERROR, "writeflagFile: Out of memory" );
@ -10734,7 +10734,7 @@ static BOOL writeFlagFile(char *pFileName)
{
return FALSE;
}
FREE(pFileData);
free(pFileData);
return TRUE;
}
@ -10838,7 +10838,7 @@ static BOOL writeProductionFile(char *pFileName)
//allocate the buffer space
pFileData = (char*)MALLOC(fileSize);
pFileData = (char*)malloc(fileSize);
if (!pFileData)
{
debug( LOG_ERROR, "writeProductionFile: Out of memory" );
@ -10886,7 +10886,7 @@ static BOOL writeProductionFile(char *pFileName)
{
return FALSE;
}
FREE(pFileData);
free(pFileData);
return TRUE;
}
@ -10953,7 +10953,7 @@ BOOL loadSaveStructLimitsV19(char *pFileData, UDWORD filesize, UDWORD numLimits)
STRUCTURE_STATS *psStats;
int SkippedRecords=0;
psSaveLimits = (SAVE_STRUCTLIMITS_V2 *) MALLOC (sizeof(SAVE_STRUCTLIMITS_V2));
psSaveLimits = (SAVE_STRUCTLIMITS_V2 *) malloc(sizeof(SAVE_STRUCTLIMITS_V2));
if (!psSaveLimits)
{
debug( LOG_ERROR, "Out of memory" );
@ -11011,7 +11011,7 @@ BOOL loadSaveStructLimitsV19(char *pFileData, UDWORD filesize, UDWORD numLimits)
debug( LOG_ERROR, "Skipped %d records in structure limits due to bad player number\n", SkippedRecords );
abort();
}
FREE(psSaveLimits);
free(psSaveLimits);
return TRUE;
}
@ -11024,7 +11024,7 @@ BOOL loadSaveStructLimitsV(char *pFileData, UDWORD filesize, UDWORD numLimits)
STRUCTURE_STATS *psStats;
int SkippedRecords=0;
psSaveLimits = (SAVE_STRUCTLIMITS*) MALLOC (sizeof(SAVE_STRUCTLIMITS));
psSaveLimits = (SAVE_STRUCTLIMITS*) malloc(sizeof(SAVE_STRUCTLIMITS));
if (!psSaveLimits)
{
debug( LOG_ERROR, "Out of memory" );
@ -11082,7 +11082,7 @@ BOOL loadSaveStructLimitsV(char *pFileData, UDWORD filesize, UDWORD numLimits)
debug( LOG_ERROR, "Skipped %d records in structure limits due to bad player number\n", SkippedRecords );
abort();
}
FREE(psSaveLimits);
free(psSaveLimits);
return TRUE;
}
// -----------------------------------------------------------------------------------------
@ -11102,7 +11102,7 @@ BOOL writeStructLimitsFile(char *pFileName)
// Allocate the data buffer
fileSize = STRUCTLIMITS_HEADER_SIZE + (totalLimits * (sizeof(SAVE_STRUCTLIMITS)));
pFileData = (char*)MALLOC(fileSize);
pFileData = (char*)malloc(fileSize);
if (pFileData == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -11141,7 +11141,7 @@ BOOL writeStructLimitsFile(char *pFileName)
// Write the data to the file
if (pFileData != NULL) {
status = saveFile(pFileName, pFileData, fileSize);
FREE(pFileData);
free(pFileData);
return status;
}
return FALSE;
@ -11245,7 +11245,7 @@ BOOL writeCommandLists(char *pFileName)
// Allocate the data buffer
fileSize = COMMAND_HEADER_SIZE + (totalDroids * (sizeof(SAVE_COMMAND)));
pFileData = (char*)MALLOC(fileSize);
pFileData = (char*)malloc(fileSize);
if (pFileData == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -11298,7 +11298,7 @@ BOOL writeCommandLists(char *pFileName)
// Write the data to the file
if (pFileData != NULL) {
status = saveFile(pFileName, pFileData, fileSize);
FREE(pFileData);
free(pFileData);
return status;
}
return FALSE;
@ -11322,7 +11322,7 @@ static BOOL writeScriptState(char *pFileName)
{
return FALSE;
}
FREE(pBuffer);
free(pBuffer);
return TRUE;
}

View File

@ -129,7 +129,7 @@ void gwShutDown(void)
if (aZoneReachable != NULL)
{
FREE(aZoneReachable);
free(aZoneReachable);
}
}
@ -150,7 +150,7 @@ BOOL gwNewGateway(SDWORD x1, SDWORD y1, SDWORD x2, SDWORD y2)
return FALSE;
}
psNew = (GATEWAY*)MALLOC(sizeof(GATEWAY));
psNew = (GATEWAY*)malloc(sizeof(GATEWAY));
if (!psNew)
{
debug( LOG_ERROR, "gwNewGateway: out of memory" );
@ -222,7 +222,7 @@ BOOL gwNewLinkGateway(SDWORD x, SDWORD y)
return FALSE;
}
psNew = (GATEWAY*)MALLOC(sizeof(GATEWAY));
psNew = (GATEWAY*)malloc(sizeof(GATEWAY));
if (!psNew)
{
debug( LOG_ERROR, "gwNewGateway: out of memory" );
@ -507,9 +507,9 @@ void gwFreeGateway(GATEWAY *psDel)
}
if(psDel->psLinks != NULL) {
FREE(psDel->psLinks);
free(psDel->psLinks);
}
FREE(psDel);
free(psDel);
}
@ -695,7 +695,7 @@ BOOL gwLinkGateways(void)
// note which zones have a gateway
aZoneReachable = (UBYTE*)MALLOC( sizeof(UBYTE) * gwNumZones );
aZoneReachable = (UBYTE*)malloc( sizeof(UBYTE) * gwNumZones );
if (aZoneReachable == NULL)
{
debug( LOG_ERROR, "gwLinkGateways: out of memory" );
@ -785,7 +785,7 @@ BOOL gwLinkGateways(void)
}
if (zone1Links+zone2Links > 0)
{
psCurr->psLinks = (GATEWAY_LINK*)MALLOC(sizeof(GATEWAY_LINK) * (zone1Links+zone2Links));
psCurr->psLinks = (GATEWAY_LINK*)malloc(sizeof(GATEWAY_LINK) * (zone1Links+zone2Links));
if (psCurr->psLinks == NULL)
{
debug( LOG_ERROR, "gwLinkGateways: out of memory" );
@ -900,7 +900,7 @@ BOOL gwNewZoneMap(void)
gwFreeZoneMap();
}
apRLEZones = (UBYTE**)MALLOC(sizeof(UBYTE *) * gwMapHeight());
apRLEZones = (UBYTE**)malloc(sizeof(UBYTE *) * gwMapHeight());
if (apRLEZones == NULL)
{
debug( LOG_ERROR, "gwNewZoneMap: Out of memory" );
@ -924,10 +924,10 @@ UBYTE * gwNewZoneLine(UDWORD Line,UDWORD Size)
ASSERT( apRLEZones != NULL,"gwNewZoneLine : NULL Zone map" );
if(apRLEZones[Line] != NULL) {
FREE(apRLEZones[Line]);
free(apRLEZones[Line]);
}
apRLEZones[Line] = (UBYTE*)MALLOC(Size);
apRLEZones[Line] = (UBYTE*)malloc(Size);
if (apRLEZones[Line] == NULL)
{
debug( LOG_ERROR, "gwNewZoneLine: Out of memory" );
@ -974,9 +974,9 @@ void gwFreeZoneMap(void)
{
for(i=0; i<gwMapHeight(); i++)
{
FREE(apRLEZones[i]);
free(apRLEZones[i]);
}
FREE(apRLEZones);
free(apRLEZones);
}
}
@ -1022,7 +1022,7 @@ BOOL gwNewEquivTable(SDWORD numZones)
"gwNewEquivTable: invalid number of zones" );
gwNumZones = numZones;
aNumEquiv = (UBYTE*)MALLOC(sizeof(UBYTE) * numZones);
aNumEquiv = (UBYTE*)malloc(sizeof(UBYTE) * numZones);
if (aNumEquiv == NULL)
{
debug( LOG_ERROR, "gwNewEquivTable: out of memory" );
@ -1034,7 +1034,7 @@ BOOL gwNewEquivTable(SDWORD numZones)
aNumEquiv[i] = 0;
}
apEquivZones = (UBYTE**)MALLOC(sizeof(UBYTE *) * numZones);
apEquivZones = (UBYTE**)malloc(sizeof(UBYTE *) * numZones);
if (apEquivZones == NULL)
{
debug( LOG_ERROR, "gwNewEquivTable: out of memory" );
@ -1056,7 +1056,7 @@ void gwFreeEquivTable(void)
if (aNumEquiv)
{
FREE(aNumEquiv);
free(aNumEquiv);
}
if (apEquivZones)
{
@ -1064,10 +1064,10 @@ void gwFreeEquivTable(void)
{
if (apEquivZones[i])
{
FREE(apEquivZones[i]);
free(apEquivZones[i]);
}
}
FREE(apEquivZones);
free(apEquivZones);
}
gwNumZones = 0;
}
@ -1085,7 +1085,7 @@ BOOL gwSetZoneEquiv(SDWORD zone, SDWORD numEquiv, UBYTE *pEquiv)
ASSERT( numEquiv <= gwNumZones,
"gwSetZoneEquiv: invalid number of zone equivalents" );
apEquivZones[zone] = (UBYTE*)MALLOC(sizeof(UBYTE) * numEquiv);
apEquivZones[zone] = (UBYTE*)malloc(sizeof(UBYTE) * numEquiv);
if (apEquivZones[zone] == NULL)
{
debug( LOG_ERROR, "gwSetZoneEquiv: out of memory" );

View File

@ -37,9 +37,6 @@
#include <string.h>
#define MALLOC(a) malloc(a)
#define FREE(a) free(a); a = NULL;
#include "typedefs.h"
#define MAP_MAXWIDTH 256
@ -525,7 +522,7 @@ BOOL gwCreateBlankZoneMap(void)
gwFreeZoneMap();
}
apRLEZones = (UBYTE**)MALLOC(sizeof(UBYTE *) * gwMapHeight());
apRLEZones = (UBYTE**)malloc(sizeof(UBYTE *) * gwMapHeight());
if (apRLEZones == NULL)
{
debug( LOG_ERROR, "gwCreateBlankZoneMap: Out of memory" );
@ -535,7 +532,7 @@ BOOL gwCreateBlankZoneMap(void)
for(i=0; i< gwMapHeight(); i++)
{
apRLEZones[i] = (UBYTE*)MALLOC(gwMapWidth() * 2);
apRLEZones[i] = (UBYTE*)malloc(gwMapWidth() * 2);
if (apRLEZones[i] == NULL)
{

View File

@ -594,7 +594,7 @@ BOOL intInitialise(void)
}
/* Create storage for Structures that can be built */
apsStructStatsList = (STRUCTURE_STATS **)MALLOC(sizeof(STRUCTURE_STATS *) *
apsStructStatsList = (STRUCTURE_STATS **)malloc(sizeof(STRUCTURE_STATS *) *
MAXSTRUCTURES);
if (!apsStructStatsList)
{
@ -604,7 +604,7 @@ BOOL intInitialise(void)
}
//create the storage for Research topics - max possible size
ppResearchList = (RESEARCH **) MALLOC(sizeof(RESEARCH *) * MAXRESEARCH);
ppResearchList = (RESEARCH **) malloc(sizeof(RESEARCH *) * MAXRESEARCH);
if (ppResearchList == NULL)
{
debug( LOG_ERROR, "Unable to allocate memory for research list" );
@ -614,10 +614,10 @@ BOOL intInitialise(void)
//create the list for the selected player
//needs to be UWORD sized for Patches
pList = (UWORD *) MALLOC(sizeof (UWORD) * MAXRESEARCH);
pSList = (UWORD *) MALLOC(sizeof (UWORD) * MAXRESEARCH);
//pList = (UBYTE *) MALLOC(sizeof (UBYTE) * MAXRESEARCH);
//pSList = (UBYTE *) MALLOC(sizeof (UBYTE) * MAXRESEARCH);
pList = (UWORD *) malloc(sizeof (UWORD) * MAXRESEARCH);
pSList = (UWORD *) malloc(sizeof (UWORD) * MAXRESEARCH);
//pList = (UBYTE *) malloc(sizeof (UBYTE) * MAXRESEARCH);
//pSList = (UBYTE *) malloc(sizeof (UBYTE) * MAXRESEARCH);
if (pList == NULL)
{
@ -633,7 +633,7 @@ BOOL intInitialise(void)
}
/* Create storage for Templates that can be built */
apsTemplateList = (DROID_TEMPLATE **)MALLOC(sizeof(DROID_TEMPLATE*) *
apsTemplateList = (DROID_TEMPLATE **)malloc(sizeof(DROID_TEMPLATE*) *
MAXTEMPLATES);
if (apsTemplateList == NULL)
{
@ -656,7 +656,7 @@ BOOL intInitialise(void)
}
/* Create storage for the feature list */
apsFeatureList = (FEATURE_STATS **)MALLOC(sizeof(FEATURE_STATS *) *
apsFeatureList = (FEATURE_STATS **)malloc(sizeof(FEATURE_STATS *) *
MAXFEATURES);
if (apsFeatureList == NULL)
{
@ -666,7 +666,7 @@ BOOL intInitialise(void)
}
/* Create storage for the component list */
apsComponentList = (COMP_BASE_STATS **)MALLOC(sizeof(COMP_BASE_STATS *) *
apsComponentList = (COMP_BASE_STATS **)malloc(sizeof(COMP_BASE_STATS *) *
MAXCOMPONENT);
if (apsComponentList == NULL)
{
@ -676,7 +676,7 @@ BOOL intInitialise(void)
}
/* Create storage for the extra systems list */
apsExtraSysList = (COMP_BASE_STATS **)MALLOC(sizeof(COMP_BASE_STATS *) *
apsExtraSysList = (COMP_BASE_STATS **)malloc(sizeof(COMP_BASE_STATS *) *
MAXEXTRASYS);
if (apsExtraSysList == NULL)
{
@ -686,7 +686,7 @@ BOOL intInitialise(void)
}
// allocate the object list
apsObjectList = (BASE_OBJECT **)MALLOC(sizeof(BASE_OBJECT *) * MAX_OBJECTS);
apsObjectList = (BASE_OBJECT **)malloc(sizeof(BASE_OBJECT *) * MAX_OBJECTS);
if (!apsObjectList)
{
debug( LOG_ERROR, "Out of memory" );
@ -695,7 +695,7 @@ BOOL intInitialise(void)
}
//allocate the order list - ONLY SIZED FOR FACTORIES AT PRESENT!!
apsListToOrder = (BASE_OBJECT **)MALLOC(sizeof(BASE_OBJECT *) * ORDERED_LIST_SIZE);
apsListToOrder = (BASE_OBJECT **)malloc(sizeof(BASE_OBJECT *) * ORDERED_LIST_SIZE);
if (!apsListToOrder)
{
debug( LOG_ERROR, "Out of memory" );
@ -843,16 +843,16 @@ void intShutDown(void)
ReleaseSnapBuffer(&InterfaceSnap);
FREE(apsStructStatsList);
FREE(ppResearchList);
FREE(pList);
FREE(pSList);
FREE(apsTemplateList);
FREE(apsFeatureList);
FREE(apsComponentList);
FREE(apsExtraSysList);
FREE(apsObjectList);
FREE(apsListToOrder);
free(apsStructStatsList);
free(ppResearchList);
free(pList);
free(pSList);
free(apsTemplateList);
free(apsFeatureList);
free(apsComponentList);
free(apsExtraSysList);
free(apsObjectList);
free(apsListToOrder);
//release the video buffers
seq_ReleaseVideoBuffers();

View File

@ -689,7 +689,7 @@ static BOOL loadLevFile(const char* filename, searchPathMode datadir) {
debug(LOG_ERROR, "loadLevFile: Parse error in %s\n", filename);
return FALSE;
}
FREE(pBuffer);
free(pBuffer);
return TRUE;
}
@ -959,7 +959,7 @@ BOOL systemInitialise(void)
{
displayBufferSize = 5000000;
}
DisplayBuffer = (char*)MALLOC(displayBufferSize);
DisplayBuffer = (char*)malloc(displayBufferSize);
if (DisplayBuffer == NULL)
{
debug( LOG_ERROR, "Unable to allocate memory for display buffer" );
@ -1059,7 +1059,7 @@ BOOL systemShutdown(void)
}
debug(LOG_MAIN, "shutting down graphics subsystem");
FREE(DisplayBuffer);
free(DisplayBuffer);
iV_ShutDown();
levShutDown();
widgShutDown();

View File

@ -2277,7 +2277,7 @@ void InitialiseButtonData(void)
UDWORD i;
for(i=0; i<NUM_OBJECTSURFACES; i++) {
ObjectSurfaces[i].Buffer = (UBYTE*)MALLOC(Width*Height);
ObjectSurfaces[i].Buffer = (UBYTE*)malloc(Width*Height);
ASSERT( ObjectSurfaces[i].Buffer!=NULL,"intInitialise : Failed to allocate Object surface" );
ObjectSurfaces[i].Surface = iV_SurfaceCreate(REND_SURFACE_USR,Width,Height,10,10,ObjectSurfaces[i].Buffer);
ASSERT( ObjectSurfaces[i].Surface!=NULL,"intInitialise : Failed to create Object surface" );
@ -2289,7 +2289,7 @@ void InitialiseButtonData(void)
}
for(i=0; i<NUM_SYSTEM0SURFACES; i++) {
System0Surfaces[i].Buffer = (UBYTE*)MALLOC(Width*Height);
System0Surfaces[i].Buffer = (UBYTE*)malloc(Width*Height);
ASSERT( System0Surfaces[i].Buffer!=NULL,"intInitialise : Failed to allocate System0 surface" );
System0Surfaces[i].Surface = iV_SurfaceCreate(REND_SURFACE_USR,Width,Height,10,10,System0Surfaces[i].Buffer);
ASSERT( System0Surfaces[i].Surface!=NULL,"intInitialise : Failed to create System0 surface" );
@ -2301,7 +2301,7 @@ void InitialiseButtonData(void)
}
for(i=0; i<NUM_TOPICSURFACES; i++) {
TopicSurfaces[i].Buffer = (UBYTE*)MALLOC(WidthTopic*HeightTopic);
TopicSurfaces[i].Buffer = (UBYTE*)malloc(WidthTopic*HeightTopic);
ASSERT( TopicSurfaces[i].Buffer!=NULL,"intInitialise : Failed to allocate Topic surface" );
TopicSurfaces[i].Surface = iV_SurfaceCreate(REND_SURFACE_USR,WidthTopic,HeightTopic,10,10,TopicSurfaces[i].Buffer);
ASSERT( TopicSurfaces[i].Surface!=NULL,"intInitialise : Failed to create Topic surface" );
@ -2313,7 +2313,7 @@ void InitialiseButtonData(void)
}
for(i=0; i<NUM_STATSURFACES; i++) {
StatSurfaces[i].Buffer = (UBYTE*)MALLOC(Width*Height);
StatSurfaces[i].Buffer = (UBYTE*)malloc(Width*Height);
ASSERT( StatSurfaces[i].Buffer!=NULL,"intInitialise : Failed to allocate Stats surface" );
StatSurfaces[i].Surface = iV_SurfaceCreate(REND_SURFACE_USR,Width,Height,10,10,StatSurfaces[i].Buffer);
ASSERT( StatSurfaces[i].Surface!=NULL,"intInitialise : Failed to create Stat surface" );
@ -2483,22 +2483,22 @@ void DeleteButtonData(void)
{
UDWORD i;
for(i=0; i<NUM_OBJECTSURFACES; i++) {
FREE(ObjectSurfaces[i].Buffer);
free(ObjectSurfaces[i].Buffer);
iV_SurfaceDestroy(ObjectSurfaces[i].Surface);
}
for(i=0; i<NUM_TOPICSURFACES; i++) {
FREE(TopicSurfaces[i].Buffer);
free(TopicSurfaces[i].Buffer);
iV_SurfaceDestroy(TopicSurfaces[i].Surface);
}
for(i=0; i<NUM_STATSURFACES; i++) {
FREE(StatSurfaces[i].Buffer);
free(StatSurfaces[i].Buffer);
iV_SurfaceDestroy(StatSurfaces[i].Surface);
}
for(i=0; i<NUM_SYSTEM0SURFACES; i++) {
FREE(System0Surfaces[i].Buffer);
free(System0Surfaces[i].Buffer);
iV_SurfaceDestroy(System0Surfaces[i].Surface);
}
}

View File

@ -2373,7 +2373,7 @@ void kf_ScriptTest( void )
eventLoadState(pBuffer, size, TRUE);
FREE(pBuffer);
free(pBuffer);
}
// --------------------------------------------------------------------------
void kf_TriggerShockWave( void )

View File

@ -504,12 +504,12 @@ KEY_MAPPING *keyAddMapping(KEY_STATUS status,KEY_CODE metaCode, KEY_CODE subCode
KEY_MAPPING *newMapping;
/* Get some memory for our binding */
newMapping = (KEY_MAPPING*)MALLOC(sizeof(KEY_MAPPING));
newMapping = (KEY_MAPPING*)malloc(sizeof(KEY_MAPPING));
ASSERT( newMapping != NULL, "Couldn't allocate memory for a key mapping" );
/* Plus one for the terminator */
newMapping->pName = (char*)MALLOC(strlen(name)+1);
newMapping->pName = (char*)malloc(strlen(name)+1);
ASSERT( newMapping->pName != NULL, "Couldn't allocate the memory for the string in a mapping" );
/* Copy over the name */
@ -598,8 +598,8 @@ KEY_MAPPING *psPrev,*psCurr;
if(psToRemove == keyMappings && keyMappings->psNext == NULL)
{
if (keyMappings->pName) FREE(keyMappings->pName); // ffs
FREE(keyMappings);
if (keyMappings->pName) free(keyMappings->pName); // ffs
free(keyMappings);
keyMappings = NULL;
numActiveMappings = 0;
return(TRUE);
@ -628,9 +628,9 @@ KEY_MAPPING *psPrev,*psCurr;
keyMappings = psCurr->psNext;
}
/* Free up the memory, first for the string */
if (psCurr->pName) FREE(psCurr->pName); // only free it if it was allocated in the first place (ffs)
if (psCurr->pName) free(psCurr->pName); // only free it if it was allocated in the first place (ffs)
/* and then for the mapping itself */
FREE(psCurr);
free(psCurr);
numActiveMappings--;
return(TRUE);
}

View File

@ -124,16 +124,16 @@ void levShutDown(void)
while (psLevels)
{
FREE(psLevels->pName);
free(psLevels->pName);
for(i=0; i<LEVEL_MAXFILES; i++)
{
if (psLevels->apDataFiles[i] != NULL)
{
FREE(psLevels->apDataFiles[i]);
free(psLevels->apDataFiles[i]);
}
}
psNext = psLevels->psNext;
FREE(psLevels);
free(psLevels);
psLevels = psNext;
}
}
@ -202,7 +202,7 @@ BOOL levParse(char *pBuffer, SDWORD size, searchPathMode datadir)
if (state == LP_START || state == LP_WAITDATA)
{
// start a new level data set
psDataSet = (LEVEL_DATASET*)MALLOC(sizeof(LEVEL_DATASET));
psDataSet = (LEVEL_DATASET*)malloc(sizeof(LEVEL_DATASET));
if (!psDataSet)
{
levError("Out of memory");
@ -375,7 +375,7 @@ BOOL levParse(char *pBuffer, SDWORD size, searchPathMode datadir)
psFoundData->psChange = psDataSet;
}
// store the level name
psDataSet->pName = (char*)MALLOC(strlen(pLevToken) + 1);
psDataSet->pName = (char*)malloc(strlen(pLevToken) + 1);
if (!psDataSet->pName)
{
levError("Out of memory");
@ -416,7 +416,7 @@ BOOL levParse(char *pBuffer, SDWORD size, searchPathMode datadir)
}
// store the data name
psDataSet->apDataFiles[currData] = (char*)MALLOC(strlen(pLevToken) + 1);
psDataSet->apDataFiles[currData] = (char*)malloc(strlen(pLevToken) + 1);
if (!psDataSet->apDataFiles[currData])
{
levError("Out of memory");

View File

@ -494,7 +494,7 @@ init://jump here from the end if re_initialising
}
//load palette
psPaletteBuffer = (iColour*)MALLOC(256 * sizeof(iColour)+1);
psPaletteBuffer = (iColour*)malloc(256 * sizeof(iColour)+1);
if (psPaletteBuffer == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -508,7 +508,7 @@ init://jump here from the end if re_initialising
return -1;
}
pal_AddNewPalette(psPaletteBuffer);
FREE(psPaletteBuffer);
free(psPaletteBuffer);
pie_LoadBackDrop(SCREEN_RANDOMBDROP);
pie_SetFogStatus(FALSE);

View File

@ -216,9 +216,9 @@ BOOL mapNew(UDWORD width, UDWORD height)
freeAllStructs();
freeAllFeatures();
proj_FreeAllProjectiles();
// FREE(psMapTiles);
// free(psMapTiles);
// mapFreeTilesAndStrips();
FREE(aMapLinePoints);
free(aMapLinePoints);
psMapTiles = NULL;
aMapLinePoints = NULL;
}
@ -252,7 +252,7 @@ BOOL mapNew(UDWORD width, UDWORD height)
*/
psMapTiles = (MAPTILE *)MALLOC(sizeof(MAPTILE) * width*height);
psMapTiles = (MAPTILE *)malloc(sizeof(MAPTILE) * width*height);
if (psMapTiles == NULL)
{
debug( LOG_ERROR, "mapNew: Out of memory" );
@ -275,7 +275,7 @@ BOOL mapNew(UDWORD width, UDWORD height)
aMapLinePoints = (TILE_COORD *)MALLOC(sizeof(TILE_COORD) * numPoints);
aMapLinePoints = (TILE_COORD *)malloc(sizeof(TILE_COORD) * numPoints);
if (!aMapLinePoints)
{
DBERROR(("Out of memory"));
@ -540,7 +540,7 @@ BOOL mapLoad(char *pFileData, UDWORD fileSize)
{
debug( LOG_ERROR, "mapLoad: Incorrect file type" );
abort();
FREE(pFileData);
free(pFileData);
return FALSE;
}
@ -555,7 +555,7 @@ BOOL mapLoad(char *pFileData, UDWORD fileSize)
{
debug( LOG_ERROR, "MapLoad: unsupported save format version %d", psHeader->version );
abort();
FREE(pFileData);
free(pFileData);
return FALSE;
}
else if (psHeader->version <= VERSION_9)
@ -570,7 +570,7 @@ BOOL mapLoad(char *pFileData, UDWORD fileSize)
{
debug( LOG_ERROR, "MapLoad: undefined save format version %d", psHeader->version );
abort();
FREE(pFileData);
free(pFileData);
return FALSE;
}
@ -622,9 +622,9 @@ BOOL mapLoad(char *pFileData, UDWORD fileSize)
freeAllStructs();
freeAllFeatures();
proj_FreeAllProjectiles();
// FREE(psMapTiles);
// free(psMapTiles);
// mapFreeTilesAndStrips();
FREE(aMapLinePoints);
free(aMapLinePoints);
psMapTiles = NULL;
aMapLinePoints = NULL;
}
@ -635,7 +635,7 @@ BOOL mapLoad(char *pFileData, UDWORD fileSize)
{
psMapTiles = (MAPTILE *)MALLOC(sizeof(MAPTILE) * width*height);
psMapTiles = (MAPTILE *)malloc(sizeof(MAPTILE) * width*height);
if (psMapTiles == NULL)
{
debug( LOG_ERROR, "mapLoad: Out of memory" );
@ -661,7 +661,7 @@ BOOL mapLoad(char *pFileData, UDWORD fileSize)
aMapLinePoints = (TILE_COORD *)MALLOC(sizeof(TILE_COORD) * numPoints);
aMapLinePoints = (TILE_COORD *)malloc(sizeof(TILE_COORD) * numPoints);
if (!aMapLinePoints)
{
DBERROR(("Out of memory"));
@ -733,7 +733,7 @@ BOOL mapSave(char **ppFileData, UDWORD *pFileSize)
*pFileSize += 1+aNumEquiv[i];
}
*ppFileData = (char*)MALLOC(*pFileSize);
*ppFileData = (char*)malloc(*pFileSize);
if (*ppFileData == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -872,7 +872,7 @@ BOOL mapSaveMission(char **ppFileData, UDWORD *pFileSize)
*pFileSize += 1+aNumEquiv[i];
}
*ppFileData = MALLOC(*pFileSize);
*ppFileData = malloc(*pFileSize);
if (*ppFileData == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -962,19 +962,19 @@ BOOL mapSaveMission(char **ppFileData, UDWORD *pFileSize)
BOOL mapShutdown(void)
{
if(psMapTiles) {
FREE(psMapTiles);
free(psMapTiles);
// mapFreeTilesAndStrips();
}
psMapTiles = NULL;
mapWidth = mapHeight = 0;
/* if(aMapLinePoints) {
FREE(aMapLinePoints);
free(aMapLinePoints);
}
aMapLinePoints = NULL;
if(aAARootTbl) {
FREE(aAARootTbl);
free(aAARootTbl);
}
aAARootTbl = NULL;
*/
@ -1130,7 +1130,7 @@ void mapRootTblInit(void)
/* Allocate the table */
aAARootTbl = MALLOC( tablecells * sizeof(AAFLOAT) );
aAARootTbl = malloc( tablecells * sizeof(AAFLOAT) );
/* Set the table values */
// incval = AADIV(AA_ONE,(tablecells - 1)); // This line is incorrect ... the second value is a constant not a fixed point value
@ -1568,7 +1568,7 @@ BOOL writeVisibilityData( char *pFileName )
fileSize = ( sizeof(struct _vis_save_header) + ( mapEntries*sizeof(UBYTE) ) );
/* Try and allocate it - freed up in same function */
pFileData = (char*)MALLOC(fileSize);
pFileData = (char*)malloc(fileSize);
/* Did we get it? */
if(!pFileData)
@ -1607,7 +1607,7 @@ BOOL writeVisibilityData( char *pFileName )
/* And free up the memory we used */
if (pFileData != NULL)
{
FREE(pFileData);
free(pFileData);
}
/* Everything is just fine! */

View File

@ -75,7 +75,7 @@ BOOL allocComponentList(COMPONENT_TYPE type, SDWORD number)
//allocate the space for the Players' component lists
for (inc=0; inc < MAX_PLAYERS; inc++)
{
apCompLists[inc][type] = (UBYTE *) MALLOC(sizeof(UBYTE) * number);
apCompLists[inc][type] = (UBYTE *) malloc(sizeof(UBYTE) * number);
if (apCompLists[inc][type] == NULL)
{
debug( LOG_ERROR, "Out of memory assigning Player Component Lists" );
@ -101,14 +101,14 @@ void freeComponentLists(void)
for (inc=0; inc < MAX_PLAYERS; inc++)
{
//free the component lists
FREE(apCompLists[inc][COMP_BODY]);
FREE(apCompLists[inc][COMP_BRAIN]);
FREE(apCompLists[inc][COMP_PROPULSION]);
FREE(apCompLists[inc][COMP_SENSOR]);
FREE(apCompLists[inc][COMP_ECM]);
FREE(apCompLists[inc][COMP_REPAIRUNIT]);
FREE(apCompLists[inc][COMP_CONSTRUCT]);
FREE(apCompLists[inc][COMP_WEAPON]);
free(apCompLists[inc][COMP_BODY]);
free(apCompLists[inc][COMP_BRAIN]);
free(apCompLists[inc][COMP_PROPULSION]);
free(apCompLists[inc][COMP_SENSOR]);
free(apCompLists[inc][COMP_ECM]);
free(apCompLists[inc][COMP_REPAIRUNIT]);
free(apCompLists[inc][COMP_CONSTRUCT]);
free(apCompLists[inc][COMP_WEAPON]);
}
}
@ -121,7 +121,7 @@ BOOL allocStructLists(void)
{
if(numStructureStats)
{
apStructTypeLists[inc] = (UBYTE *) MALLOC(sizeof(UBYTE) *
apStructTypeLists[inc] = (UBYTE *) malloc(sizeof(UBYTE) *
numStructureStats);
if (apStructTypeLists[inc] == NULL)
{
@ -153,7 +153,7 @@ void freeStructureLists(void)
{
//free the structure lists
if(apStructTypeLists[inc]) {
FREE(apStructTypeLists[inc]);
free(apStructTypeLists[inc]);
}
}
}

View File

@ -576,7 +576,7 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize)
//allocate space for text strings
if (psViewData->numText)
{
psViewData->ppTextMsg = (char **) MALLOC(psViewData->numText *
psViewData->ppTextMsg = (char **) malloc(psViewData->numText *
sizeof(char *));
}
@ -609,7 +609,7 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize)
switch (psViewData->type)
{
case VIEW_RES:
psViewData->pData = (VIEW_RESEARCH *) MALLOC(sizeof(VIEW_RESEARCH));
psViewData->pData = (VIEW_RESEARCH *) malloc(sizeof(VIEW_RESEARCH));
if (psViewData->pData == NULL)
{
debug( LOG_ERROR, "Unable to allocate memory" );
@ -652,7 +652,7 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize)
if (strcmp(audioName, "0"))
{
//allocate space
psViewRes->pAudio = (char *) MALLOC(strlen(audioName) + 1);
psViewRes->pAudio = (char *) malloc(strlen(audioName) + 1);
if (psViewRes->pAudio == NULL)
{
debug( LOG_ERROR, "loadViewData - Out of memory" );
@ -672,7 +672,7 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize)
case VIEW_RPLX:
// This is now also used for the stream playing on the PSX
// NOTE: on the psx the last entry (audioID) is used as the number of frames in the stream
psViewData->pData = (VIEW_REPLAY *) MALLOC(sizeof(VIEW_REPLAY));
psViewData->pData = (VIEW_REPLAY *) malloc(sizeof(VIEW_REPLAY));
if (psViewData->pData == NULL)
{
debug( LOG_ERROR, "Unable to allocate memory" );
@ -696,7 +696,7 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize)
psViewReplay->numSeq = (UBYTE)count;
//allocate space for the sequences
psViewReplay->pSeqList = (SEQ_DISPLAY*) MALLOC(psViewReplay->numSeq *
psViewReplay->pSeqList = (SEQ_DISPLAY*) malloc(psViewReplay->numSeq *
sizeof(SEQ_DISPLAY));
//read in the data for the sequences
@ -744,7 +744,7 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize)
//allocate space for text strings
if (psViewReplay->pSeqList[dataInc].numText)
{
psViewReplay->pSeqList[dataInc].ppTextMsg = (char **) MALLOC(
psViewReplay->pSeqList[dataInc].ppTextMsg = (char **) malloc(
psViewReplay->pSeqList[dataInc].numText * sizeof(char *));
}
//read in the data for the text strings
@ -780,7 +780,7 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize)
if (strcmp(audioName, "0"))
{
//allocate space
psViewReplay->pSeqList[dataInc].pAudio = (char *) MALLOC(
psViewReplay->pSeqList[dataInc].pAudio = (char *) malloc(
strlen(audioName) + 1);
if (psViewReplay->pSeqList[dataInc].pAudio == NULL)
{
@ -799,7 +799,7 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize)
break;
case VIEW_PROX:
psViewData->pData = (VIEW_PROXIMITY *) MALLOC(sizeof(VIEW_PROXIMITY));
psViewData->pData = (VIEW_PROXIMITY *) malloc(sizeof(VIEW_PROXIMITY));
if (psViewData->pData == NULL)
{
debug( LOG_ERROR, "Unable to allocate memory" );
@ -881,7 +881,7 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize)
//increment the list to the start of the next storage block
psViewData++;
}
// FREE(pData);
// free(pData);
//return TRUE;
return pData;
@ -947,11 +947,11 @@ void viewDataShutDown(VIEWDATA *psViewData)
//check for any messages using this viewdata
checkMessages((MSG_VIEWDATA *)psViewData);
FREE(psViewData->pName);
free(psViewData->pName);
//free the space allocated for the text messages
if (psViewData->numText)
{
FREE(psViewData->ppTextMsg);
free(psViewData->ppTextMsg);
}
//free the space allocated for multiple sequences
@ -965,14 +965,14 @@ void viewDataShutDown(VIEWDATA *psViewData)
//free the space allocated for the text messages
if (psViewReplay->pSeqList[seqInc].numText)
{
FREE(psViewReplay->pSeqList[seqInc].ppTextMsg);
free(psViewReplay->pSeqList[seqInc].ppTextMsg);
}
if (psViewReplay->pSeqList[seqInc].pAudio)
{
FREE(psViewReplay->pSeqList[seqInc].pAudio);
free(psViewReplay->pSeqList[seqInc].pAudio);
}
}
FREE(psViewReplay->pSeqList);
free(psViewReplay->pSeqList);
}
}
else if (psViewData->type == VIEW_RES)
@ -980,12 +980,12 @@ void viewDataShutDown(VIEWDATA *psViewData)
psViewRes = (VIEW_RESEARCH *)psViewData->pData;
if (psViewRes->pAudio)
{
FREE(psViewRes->pAudio);
free(psViewRes->pAudio);
}
}
FREE(psViewData->pData);
free(psViewData->pData);
}
FREE(psList->psViewData);
free(psList->psViewData);
//remove viewData list from the heap
if (psList == apsViewData)
{

View File

@ -410,9 +410,9 @@ BOOL missionShutDown(void)
releaseAllProxDisp();
gwShutDown();
//flag positions go with structs
// FREE(psMapTiles);
// free(psMapTiles);
// mapFreeTilesAndStrips();
//FREE(aMapLinePoints);
//free(aMapLinePoints);
for (inc = 0; inc < MAX_PLAYERS; inc++)
{
@ -1057,9 +1057,9 @@ void restoreMissionData(void)
freeAllFeatures();
gwShutDown();
mapShutdown();
// FREE(psMapTiles);
// free(psMapTiles);
// mapFreeTilesAndStrips();
//FREE(aMapLinePoints);
//free(aMapLinePoints);
//releaseAllProxDisp();
//flag positions go with structs

View File

@ -1316,7 +1316,7 @@ BOOL receiveWholeDroid(NETMSG *m)
NetGet(m,sizecount,pD->psTarStats[0]); sizecount+=sizeof(pD->psTarStats[0]); //later!
//store the droid for later.
tempDroid = (DROIDSTORE*)MALLOC(sizeof(DROIDSTORE));
tempDroid = (DROIDSTORE*)malloc(sizeof(DROIDSTORE));
tempDroid->psDroid = pD;
tempDroid->psNext = tempDroidList;
tempDroidList = tempDroid;

View File

@ -2868,7 +2868,7 @@ BOOL startMultiOptions(BOOL bReenter)
if(ingame.numStructureLimits)
{
ingame.numStructureLimits = 0;
FREE(ingame.pStructureLimits);
free(ingame.pStructureLimits);
}
// check the registry for setup entries and set game options.

View File

@ -651,7 +651,7 @@ BOOL ProcessDroidOrders(void)
addDroid(pD, apsDroidLists); // add the droid to the world.
pStore = tempDroidList->psNext; // goto next droid.
FREE(tempDroidList);
free(tempDroidList);
tempDroidList = pStore;
if(tempDroidList)

View File

@ -335,7 +335,7 @@ void createLimitSet(void)
if(ingame.numStructureLimits) // free the old set if required.
{
ingame.numStructureLimits = 0;
FREE(ingame.pStructureLimits);
free(ingame.pStructureLimits);
}
numchanges =0; // count number of changes
@ -348,7 +348,7 @@ void createLimitSet(void)
}
//close your eyes now
pChanges = (UBYTE*)MALLOC(numchanges*(sizeof(UDWORD)+sizeof(UBYTE))); // allocate some mem for this.
pChanges = (UBYTE*)malloc(numchanges*(sizeof(UDWORD)+sizeof(UBYTE))); // allocate some mem for this.
pEntry = pChanges;
for(i=0;i<numStructureStats;i++) // prepare chunk.
@ -410,7 +410,7 @@ void applyLimitSet(void)
// free.
if( ingame.numStructureLimits )
{
FREE(ingame.pStructureLimits);
free(ingame.pStructureLimits);
ingame.numStructureLimits = 0;
}
}

View File

@ -186,7 +186,7 @@ void recvOptions(NETMSG *pMsg)
if(ingame.numStructureLimits) // free old limits.
{
ingame.numStructureLimits = 0;
FREE(ingame.pStructureLimits);
free(ingame.pStructureLimits);
}
NetGet(pMsg,pos,player2dpid);
@ -225,7 +225,7 @@ void recvOptions(NETMSG *pMsg)
pos += sizeof(ingame.numStructureLimits);
if(ingame.numStructureLimits)
{
ingame.pStructureLimits = (UBYTE*)MALLOC(ingame.numStructureLimits*(sizeof(UDWORD)+sizeof(UBYTE))); // malloc some room
ingame.pStructureLimits = (UBYTE*)malloc(ingame.numStructureLimits*(sizeof(UDWORD)+sizeof(UBYTE))); // malloc some room
memcpy(ingame.pStructureLimits, &(pMsg->body[pos]) ,ingame.numStructureLimits*(sizeof(UDWORD)+sizeof(UBYTE)));
}
@ -573,14 +573,14 @@ BOOL multiShutdown(void)
{
pF = Force.pMembers;
Force.pMembers = pF->psNext;
FREE(pF);
free(pF);
}
debug(LOG_MAIN, "free game data (structure limits)");
if(ingame.numStructureLimits)
{
ingame.numStructureLimits = 0;
FREE(ingame.pStructureLimits);
free(ingame.pStructureLimits);
}
return TRUE;
@ -1138,7 +1138,7 @@ BOOL multiGameShutdown(void)
if(ingame.numStructureLimits)
{
ingame.numStructureLimits = 0;
FREE(ingame.pStructureLimits);
free(ingame.pStructureLimits);
}
ingame.localJoiningInProgress = FALSE; // clean up

View File

@ -96,7 +96,7 @@ BOOL addToForce(DROID_TEMPLATE *templ)
psTempl = psTempl->psNext);
if(!psTempl)
{
pT = (DROID_TEMPLATE*)MALLOC(sizeof(DROID_TEMPLATE));
pT = (DROID_TEMPLATE*)malloc(sizeof(DROID_TEMPLATE));
if ( !pT)
{
return FALSE;
@ -117,7 +117,7 @@ BOOL addToForce(DROID_TEMPLATE *templ)
}
// add droid.
pF = (FORCE_MEMBER*)MALLOC(sizeof(FORCE_MEMBER)); // create a slot in the force.
pF = (FORCE_MEMBER*)malloc(sizeof(FORCE_MEMBER)); // create a slot in the force.
if (!pF)
{
return FALSE;
@ -159,7 +159,7 @@ BOOL removeFromForce(UDWORD number)
}
templateid = pF->pTempl->ref;
FREE(pF);
free(pF);
// now check if template is still in use.
inuse = FALSE;
@ -193,7 +193,7 @@ BOOL removeFromForce(UDWORD number)
{
Force.pForceTemplates = psCurr->psNext; // It's at the root
}
FREE(psCurr); // Delete the template.
free(psCurr); // Delete the template.
}
}
@ -488,7 +488,7 @@ BOOL loadForce(char *name)
// old method
for(tcount;tcount!=0;tcount--) // get templates
{
psTempl = MALLOC(sizeof(DROID_TEMPLATE));
psTempl = malloc(sizeof(DROID_TEMPLATE));
if (psTempl == NULL) // !HEAP_ALLOC(psTemplateHeap, &psTempl))
{
debug( LOG_ERROR, "Couldn't allocate template for %s", fileName );
@ -643,7 +643,7 @@ BOOL loadMultiStats(char *sPlayerName,PLAYERSTATS *playerStats)
//set the name. ASSUME STRING IS LONG ENOUGH!
strcpy(sPlayerName,st.name);
FREE(pFileData);
free(pFileData);
// reset recent scores
playerStats->recentKills = 0;

View File

@ -133,7 +133,7 @@ PLAYER_AI *asPlayerAI;
/* Initialise the player AI system */
BOOL playerInitialise(void)
{
asPlayerAI = (PLAYER_AI *)MALLOC(sizeof(PLAYER_AI) * MAX_PLAYERS);
asPlayerAI = (PLAYER_AI *)malloc(sizeof(PLAYER_AI) * MAX_PLAYERS);
if (!asPlayerAI)
{
debug( LOG_ERROR, "Out of memory" );
@ -156,7 +156,7 @@ void playerReset(void)
/* Shutdown the player AI system */
void playerShutDown(void)
{
FREE(asPlayerAI);
free(asPlayerAI);
}

View File

@ -82,7 +82,7 @@ BOOL allocPlayerPower(void)
//allocate the space for the structure
for (player = 0; player < MAX_PLAYERS; player++)
{
asPower[player] = (PLAYER_POWER *) MALLOC (sizeof(PLAYER_POWER));
asPower[player] = (PLAYER_POWER *) malloc(sizeof(PLAYER_POWER));
if (asPower[player] == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -125,7 +125,7 @@ void releasePlayerPower(void)
{
if (asPower[player])
{
FREE(asPower[player]);
free(asPower[player]);
}
}
}

View File

@ -153,7 +153,7 @@ BOOL InitRadar(void)
{
UBYTE color;
radarBuffer = (UBYTE*)MALLOC(RADWIDTH*RADHEIGHT);
radarBuffer = (UBYTE*)malloc(RADWIDTH*RADHEIGHT);
if(radarBuffer==NULL) return FALSE;
memset(radarBuffer,0,RADWIDTH*RADHEIGHT);
@ -204,7 +204,7 @@ BOOL ShutdownRadar(void)
pie_ShutdownRadar();
FREE(radarBuffer);
free(radarBuffer);
return TRUE;
}

View File

@ -161,7 +161,7 @@ BOOL researchInitVars(void)
psCBLastResearch = NULL;
asResearch = NULL;
//research is a pre-defined size now
asResearch = (RESEARCH *)MALLOC(sizeof(RESEARCH)* MAX_RESEARCH);
asResearch = (RESEARCH *)malloc(sizeof(RESEARCH)* MAX_RESEARCH);
if (asResearch == NULL)
{
debug( LOG_ERROR, "Research Stats - Out of memory" );
@ -173,7 +173,7 @@ BOOL researchInitVars(void)
//create the PLAYER_RESEARCH arrays
for (i=0; i < MAX_PLAYERS; i++)
{
asPlayerResList[i] = (PLAYER_RESEARCH*)MALLOC(MAX_RESEARCH *
asPlayerResList[i] = (PLAYER_RESEARCH*)malloc(MAX_RESEARCH *
sizeof(PLAYER_RESEARCH));
if (asPlayerResList[i] == NULL)
{
@ -188,8 +188,8 @@ BOOL researchInitVars(void)
//and deal with all the other arrays for research
//needs to be UWORD sized for the Patches
pResearchPR = (UWORD *) MALLOC(sizeof(UWORD) * MAX_RESEARCH_PR);
//pResearchPR = (UBYTE *) MALLOC(sizeof(UBYTE) * MAX_RESEARCH_PR);
pResearchPR = (UWORD *) malloc(sizeof(UWORD) * MAX_RESEARCH_PR);
//pResearchPR = (UBYTE *) malloc(sizeof(UBYTE) * MAX_RESEARCH_PR);
if (pResearchPR == NULL)
{
debug( LOG_ERROR, "Research Stats - Out of memory" );
@ -200,7 +200,7 @@ BOOL researchInitVars(void)
memset(pResearchPR, 0, (MAX_RESEARCH_PR * sizeof(UWORD)));
//memset(pResearchPR, 0, (MAX_RESEARCH_PR * sizeof(UBYTE)));
pResearchStructPR = (UWORD *) MALLOC(sizeof(UWORD) * MAX_RESEARCH_STRUCT_PR);
pResearchStructPR = (UWORD *) malloc(sizeof(UWORD) * MAX_RESEARCH_STRUCT_PR);
if (pResearchStructPR == NULL)
{
debug( LOG_ERROR, "Research Stats - Out of memory" );
@ -209,7 +209,7 @@ BOOL researchInitVars(void)
}
memset(pResearchStructPR, 0, (MAX_RESEARCH_STRUCT_PR * sizeof(UWORD)));
pResearchFunc = (FUNCTION **) MALLOC(sizeof(FUNCTION *) * MAX_RESEARCH_FUNC);
pResearchFunc = (FUNCTION **) malloc(sizeof(FUNCTION *) * MAX_RESEARCH_FUNC);
if (pResearchFunc == NULL)
{
debug( LOG_ERROR, "Research Stats - Out of memory" );
@ -218,7 +218,7 @@ BOOL researchInitVars(void)
}
memset(pResearchFunc, 0, (MAX_RESEARCH_FUNC * sizeof(FUNCTION *)));
pResearchStructRed = (UWORD *) MALLOC(sizeof(UWORD) * MAX_RESEARCH_STRUCT_RED);
pResearchStructRed = (UWORD *) malloc(sizeof(UWORD) * MAX_RESEARCH_STRUCT_RED);
if (pResearchStructRed == NULL)
{
debug( LOG_ERROR, "Research Stats - Out of memory" );
@ -227,7 +227,7 @@ BOOL researchInitVars(void)
}
memset(pResearchStructRed, 0, (MAX_RESEARCH_STRUCT_RED * sizeof(UWORD)));
pResearchArteRed = (COMP_BASE_STATS **) MALLOC(sizeof(COMP_BASE_STATS *) * MAX_RESEARCH_ARTE_RED);
pResearchArteRed = (COMP_BASE_STATS **) malloc(sizeof(COMP_BASE_STATS *) * MAX_RESEARCH_ARTE_RED);
if (pResearchArteRed == NULL)
{
debug( LOG_ERROR, "Research Stats - Out of memory" );
@ -236,7 +236,7 @@ BOOL researchInitVars(void)
}
memset(pResearchArteRed, 0, (MAX_RESEARCH_ARTE_RED * sizeof(COMP_BASE_STATS *)));
pResearchStructRes = (UWORD *) MALLOC(sizeof(UWORD) * MAX_RESEARCH_STRUCT_RES);
pResearchStructRes = (UWORD *) malloc(sizeof(UWORD) * MAX_RESEARCH_STRUCT_RES);
if (pResearchStructRes == NULL)
{
debug( LOG_ERROR, "Research Stats - Out of memory" );
@ -245,7 +245,7 @@ BOOL researchInitVars(void)
}
memset(pResearchStructRes, 0, (MAX_RESEARCH_STRUCT_RES * sizeof(UWORD)));
pResearchArteRes = (COMP_BASE_STATS **) MALLOC(sizeof(COMP_BASE_STATS *) * MAX_RESEARCH_ARTE_RES);
pResearchArteRes = (COMP_BASE_STATS **) malloc(sizeof(COMP_BASE_STATS *) * MAX_RESEARCH_ARTE_RES);
if (pResearchArteRes == NULL)
{
debug( LOG_ERROR, "Research Stats - Out of memory" );
@ -254,7 +254,7 @@ BOOL researchInitVars(void)
}
memset(pResearchArteRes, 0, (MAX_RESEARCH_ARTE_RES * sizeof(COMP_BASE_STATS *)));
pResearchArteRep = (COMP_BASE_STATS **) MALLOC(sizeof(COMP_BASE_STATS *) * MAX_RESEARCH_ARTE_RES);
pResearchArteRep = (COMP_BASE_STATS **) malloc(sizeof(COMP_BASE_STATS *) * MAX_RESEARCH_ARTE_RES);
if (pResearchArteRep == NULL)
{
debug( LOG_ERROR, "Research Stats - Out of memory" );
@ -291,7 +291,7 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize)
pStartResearchData = pResearchData;
researchCount = numCR(pResearchData, bufferSize);
/*asResearch = (RESEARCH *)MALLOC(sizeof(RESEARCH)*researchCount);
/*asResearch = (RESEARCH *)malloc(sizeof(RESEARCH)*researchCount);
if (asResearch == NULL)
{
DBERROR(("Research Stats - Out of memory"));
@ -561,7 +561,7 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize)
//redundancies - artefacts
if (pResearch->numRedArtefacts > 0)
{
/*pResearch->pRedArtefacts = (COMP_BASE_STATS **) MALLOC(pResearch->
/*pResearch->pRedArtefacts = (COMP_BASE_STATS **) malloc(pResearch->
numRedArtefacts*sizeof(COMP_BASE_STATS *));
if (pResearch->pRedArtefacts == NULL)
{
@ -583,7 +583,7 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize)
//results
if (pResearch->numArteResults > 0)
{
/*pResearch->pArtefactResults = (COMP_BASE_STATS **) MALLOC(pResearch->
/*pResearch->pArtefactResults = (COMP_BASE_STATS **) malloc(pResearch->
numArteResults*sizeof(COMP_BASE_STATS *));
if (pResearch->pArtefactResults == NULL)
{
@ -606,7 +606,7 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize)
//replacements
if (pResearch->numArteResults > 0)
{
/*pResearch->pReplacedArtefacts = (COMP_BASE_STATS **) MALLOC(pResearch->
/*pResearch->pReplacedArtefacts = (COMP_BASE_STATS **) malloc(pResearch->
numArteResults*sizeof(COMP_BASE_STATS *));
if (pResearch->pReplacedArtefacts == NULL)
{
@ -629,7 +629,7 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize)
//allocate storage for the functions
if (pResearch->numFunctions > 0)
{
/*pResearch->pFunctionList = (FUNCTION**)MALLOC(pResearch->
/*pResearch->pFunctionList = (FUNCTION**)malloc(pResearch->
numFunctions*sizeof(FUNCTION*));
if (pResearch->pFunctionList == NULL)
{
@ -652,7 +652,7 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize)
//allocate storage for the pre-requisities
if (pResearch->numPRRequired > 0)
{
/*pResearch->pPRList = (UDWORD*)MALLOC(pResearch->
/*pResearch->pPRList = (UDWORD*)malloc(pResearch->
numPRRequired*sizeof(UDWORD));
if (pResearch->pPRList == NULL)
{
@ -678,7 +678,7 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize)
//requirements
if (pResearch->numStructures > 0)
{
/*pResearch->pStructList = (UDWORD *) MALLOC(pResearch->
/*pResearch->pStructList = (UDWORD *) malloc(pResearch->
numStructures*sizeof(UDWORD));
if (pResearch->pStructList == NULL)
{
@ -701,7 +701,7 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize)
//redundancies
if (pResearch->numRedStructs > 0)
{
/*pResearch->pRedStructs = (UDWORD *) MALLOC(pResearch->
/*pResearch->pRedStructs = (UDWORD *) malloc(pResearch->
numRedStructs*sizeof(UDWORD));
if (pResearch->pRedStructs == NULL)
{
@ -723,7 +723,7 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize)
//results
if (pResearch->numStructResults > 0)
{
/*pResearch->pStructureResults = (UDWORD *) MALLOC(pResearch->
/*pResearch->pStructureResults = (UDWORD *) malloc(pResearch->
numStructResults*sizeof(UDWORD));
if (pResearch->pStructureResults == NULL)
{
@ -765,14 +765,14 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize)
//increment the list to the start of the next storage block
pResearch++;
}
// FREE(pStartResearchData);
// free(pStartResearchData);
//Do this in initResearch now since there is a Max Research
//now we know how many research topics there are we can create the
//PLAYER_RESEARCH arrays
/*for (i=0; i < MAX_PLAYERS; i++)
{
asPlayerResList[i] = (PLAYER_RESEARCH*)MALLOC(numResearch *
asPlayerResList[i] = (PLAYER_RESEARCH*)malloc(numResearch *
sizeof(PLAYER_RESEARCH));
if (asPlayerResList[i] == NULL)
{
@ -879,7 +879,7 @@ BOOL loadResearchPR(char *pPRData, UDWORD bufferSize)
//increment the pointer to the start of the next record
pPRData = strchr(pPRData,'\n') + 1;
}
// FREE(pStartPRData);
// free(pStartPRData);
return TRUE;
}
@ -1040,7 +1040,7 @@ BOOL loadResearchArtefacts(char *pArteData, UDWORD bufferSize, UDWORD listNumber
//increment the pointer to the start of the next record
pArteData = strchr(pArteData,'\n') + 1;
}
// FREE(pStartArteData);
// free(pStartArteData);
return TRUE;
}
@ -1189,7 +1189,7 @@ BOOL loadResearchStructures(char *pStructData, UDWORD bufferSize,UDWORD listNumb
//increment the pointer to the start of the next record
pStructData = strchr(pStructData,'\n') + 1;
}
// FREE(pStartStructData);
// free(pStartStructData);
return TRUE;
}
@ -1290,7 +1290,7 @@ BOOL loadResearchFunctions(char *pFunctionData, UDWORD bufferSize)
//increment the pointer to the start of the next record
pFunctionData = strchr(pFunctionData,'\n') + 1;
}
// FREE(pStartFunctionData);
// free(pStartFunctionData);
return TRUE;
}
@ -2098,38 +2098,38 @@ BOOL ResearchShutDown(void)
for (inc=0; inc < numResearch; inc++)
{
#if !defined (RESOURCE_NAMES) && !defined (STORE_RESOURCE_ID)
FREE(pList->pName);
free(pList->pName);
#endif
//FREE(pList->pTechnologyName);
// FREE(pList->pSubGroupName);
//free(pList->pTechnologyName);
// free(pList->pSubGroupName);
if (pList->numRedArtefacts > 0)
{
FREE(pList->pRedArtefacts);
free(pList->pRedArtefacts);
}
if (pList->numArteResults > 0)
{
FREE(pList->pArtefactResults);
FREE(pList->pReplacedArtefacts);
free(pList->pArtefactResults);
free(pList->pReplacedArtefacts);
}
if (pList->numPRRequired > 0)
{
FREE(pList->pPRList);
free(pList->pPRList);
}
if (pList->numStructures > 0)
{
FREE(pList->pStructList);
free(pList->pStructList);
}
if (pList->numRedStructs > 0)
{
FREE(pList->pRedStructs);
free(pList->pRedStructs);
}
if (pList->numStructResults > 0)
{
FREE(pList->pStructureResults);
free(pList->pStructureResults);
}
if (pList->numFunctions > 0)
{
FREE(pList->pFunctionList);
free(pList->pFunctionList);
}
pList++;
}
@ -2177,19 +2177,19 @@ BOOL ResearchRelease(void)
UBYTE i;
//free all the pre-defined arrays for research
FREE(asResearch);
free(asResearch);
for (i=0; i < MAX_PLAYERS; i++)
{
FREE(asPlayerResList[i]);
free(asPlayerResList[i]);
}
FREE(pResearchPR);
FREE(pResearchStructPR);
FREE(pResearchFunc);
FREE(pResearchStructRed);
FREE(pResearchArteRed);
FREE(pResearchStructRes);
FREE(pResearchArteRes);
FREE(pResearchArteRep);
free(pResearchPR);
free(pResearchStructPR);
free(pResearchFunc);
free(pResearchStructRed);
free(pResearchArteRed);
free(pResearchStructRes);
free(pResearchArteRes);
free(pResearchArteRep);
return TRUE;
}

View File

@ -491,7 +491,7 @@ SCORE_SAVEHEADER *psHeader; // Pointer to the header part of the file
fileSize = ( sizeof(struct _score_save_header) + sizeof(struct mission_data) );
/* Try and allocate it - freed up in same function */
pFileData = (char*)MALLOC(fileSize);
pFileData = (char*)malloc(fileSize);
/* Did we get it? */
if(!pFileData)
@ -542,7 +542,7 @@ SCORE_SAVEHEADER *psHeader; // Pointer to the header part of the file
/* And free up the memory we used */
if (pFileData != NULL)
{
FREE(pFileData);
free(pFileData);
}
return status;
}

View File

@ -2263,7 +2263,7 @@ BOOL skAddTemplate(void)
return FALSE;
}
psTempl =(DROID_TEMPLATE *)stempl;
// psT = MALLOC(sizeof(SKIRMISHSTORE));
// psT = malloc(sizeof(SKIRMISHSTORE));
HEAP_ALLOC(psTemplateHeap,&psT);
if ( !psT)
{

View File

@ -9958,7 +9958,7 @@ VIEWDATA *HelpViewData(SDWORD sender, char *textMsg, UDWORD LocX, UDWORD LocY)
//allocate message space
psViewData = (VIEWDATA *)MALLOC(sizeof(VIEWDATA));
psViewData = (VIEWDATA *)malloc(sizeof(VIEWDATA));
if (psViewData == NULL)
{
debug(LOG_ERROR,"prepairHelpViewData() - Unable to allocate memory for viewdata");
@ -9977,7 +9977,7 @@ VIEWDATA *HelpViewData(SDWORD sender, char *textMsg, UDWORD LocX, UDWORD LocY)
name[2] = 'l';
name[3] = 'p';
name[4] = '\0';
psViewData->pName = (char *)MALLOC((strlen(name))+1);
psViewData->pName = (char *)malloc((strlen(name))+1);
if (psViewData->pName == NULL)
{
debug(LOG_ERROR,"prepairHelpViewData() - ViewData Name - Out of memory");
@ -9987,7 +9987,7 @@ VIEWDATA *HelpViewData(SDWORD sender, char *textMsg, UDWORD LocX, UDWORD LocY)
strcpy(psViewData->pName,name);
//allocate space for text strings
psViewData->ppTextMsg = (char **) MALLOC(sizeof(char *));
psViewData->ppTextMsg = (char **) malloc(sizeof(char *));
//store text message pointer
psViewData->ppTextMsg[0] = textMsg;
@ -9996,7 +9996,7 @@ VIEWDATA *HelpViewData(SDWORD sender, char *textMsg, UDWORD LocX, UDWORD LocY)
psViewData->type = VIEW_HELP; //was VIEW_PROX
//allocate memory for blip location etc
psViewData->pData = (VIEW_PROXIMITY *) MALLOC(sizeof(VIEW_PROXIMITY));
psViewData->pData = (VIEW_PROXIMITY *) malloc(sizeof(VIEW_PROXIMITY));
if (psViewData->pData == NULL)
{
@ -10834,7 +10834,7 @@ BOOL scrGetChatCmdDescription(void)
}
/* Allocate memory for the comamnd string */
pChatCommand = (char*)MALLOC(MAXSTRLEN);
pChatCommand = (char*)malloc(MAXSTRLEN);
ASSERT(pChatCommand != NULL, "scrGetCommandDescription: out of memory");
@ -10847,11 +10847,11 @@ BOOL scrGetChatCmdDescription(void)
if (!stackPushResult(VAL_STRING, &scrFunctionResult))
{
debug(LOG_ERROR, "scrGetCommandDescription(): failed to push result");
FREE(pChatCommand);
free(pChatCommand);
return FALSE;
}
FREE(pChatCommand);
free(pChatCommand);
return TRUE;
}

View File

@ -72,8 +72,8 @@ void scrvShutDown(void)
psCurr = psContextStore;
psContextStore = psContextStore->psNext;
FREE(psCurr->pIDString);
FREE(psCurr);
free(psCurr->pIDString);
free(psCurr);
}
}
@ -87,8 +87,8 @@ void scrvReset(void)
psCurr = psContextStore;
psContextStore = psContextStore->psNext;
FREE(psCurr->pIDString);
FREE(psCurr);
free(psCurr->pIDString);
free(psCurr);
}
psContextStore = NULL;
@ -101,14 +101,14 @@ BOOL scrvAddContext(char *pID, SCRIPT_CONTEXT *psContext, SCRV_TYPE type)
{
SCRV_STORE *psNew;
psNew = (SCRV_STORE*)MALLOC(sizeof(SCRV_STORE));
psNew = (SCRV_STORE*)malloc(sizeof(SCRV_STORE));
if (!psNew)
{
debug( LOG_ERROR, "scrvAddContext: Out of memory" );
abort();
return FALSE;
}
psNew->pIDString = (char*)MALLOC(strlen(pID) + 1);
psNew->pIDString = (char*)malloc(strlen(pID) + 1);
if (!psNew->pIDString)
{
debug( LOG_ERROR, "scrvAddContext: Out of memory" );
@ -371,7 +371,7 @@ BOOL scrvGetString(char *pStringID, char **ppString)
psVal->v.sval));
return FALSE;
}
FREE(psVal->v.sval);
free(psVal->v.sval);
psVal->v.ival = compIndex;
break;
case ST_PROPULSION:
@ -387,7 +387,7 @@ BOOL scrvGetString(char *pStringID, char **ppString)
psVal->v.sval));
return FALSE;
}
FREE(psVal->v.sval);
free(psVal->v.sval);
psVal->v.ival = compIndex;
break;
case ST_ECM:
@ -403,7 +403,7 @@ BOOL scrvGetString(char *pStringID, char **ppString)
psVal->v.sval));
return FALSE;
}
FREE(psVal->v.sval);
free(psVal->v.sval);
psVal->v.ival = compIndex;
break;
case ST_SENSOR:
@ -419,7 +419,7 @@ BOOL scrvGetString(char *pStringID, char **ppString)
psVal->v.sval));
return FALSE;
}
FREE(psVal->v.sval);
free(psVal->v.sval);
psVal->v.ival = compIndex;
break;
case ST_CONSTRUCT:
@ -435,7 +435,7 @@ BOOL scrvGetString(char *pStringID, char **ppString)
psVal->v.sval));
return FALSE;
}
FREE(psVal->v.sval);
free(psVal->v.sval);
psVal->v.ival = compIndex;
break;
case ST_WEAPON:
@ -451,7 +451,7 @@ BOOL scrvGetString(char *pStringID, char **ppString)
psVal->v.sval));
return FALSE;
}
FREE(psVal->v.sval);
free(psVal->v.sval);
psVal->v.ival = compIndex;
break;
default:

View File

@ -319,8 +319,8 @@ UDWORD *toClear;
BOOL seq_ReleaseVideoBuffers(void)
{
FREE(pVideoBuffer);
FREE(pVideoPalette);
free(pVideoBuffer);
free(pVideoPalette);
return TRUE;
}
@ -330,13 +330,13 @@ BOOL seq_SetupVideoBuffers(void)
UBYTE r,g,b;
//assume 320 * 240 * 16bit playback surface
mallocSize = (RPL_WIDTH*RPL_HEIGHT*RPL_DEPTH);
if ((pVideoBuffer = (char*)MALLOC(mallocSize)) == NULL)
if ((pVideoBuffer = (char*)malloc(mallocSize)) == NULL)
{
return FALSE;
}
mallocSize = 1<<(RPL_BITS_555);//palette only used in 555mode
if ((pVideoPalette = (char*)MALLOC(mallocSize)) == NULL)
if ((pVideoPalette = (char*)malloc(mallocSize)) == NULL)
{
return FALSE;
}

View File

@ -161,7 +161,7 @@ static char NotUsedString[50]; // Dummy area for scanf
#define ALLOC_STATS(numEntries, list, listSize, type) \
ASSERT( (numEntries) < REF_RANGE, \
"allocStats: number of stats entries too large for " #type );\
(list) = (type *)MALLOC(sizeof(type) * (numEntries)); \
(list) = (type *)malloc(sizeof(type) * (numEntries)); \
if ((list) == NULL) \
{ \
debug( LOG_ERROR, "Out of memory" ); \
@ -245,13 +245,13 @@ void statsDealloc(COMP_BASE_STATS* pStats, UDWORD listSize, UDWORD structureSize
for (inc=0; inc < listSize; inc++)
{
FREE(pStatList->pName);
free(pStatList->pName);
address += structureSize;
pStatList = (COMP_BASE_STATS *) address;
}
#endif
FREE (pStats);
free(pStats);
}
@ -276,11 +276,11 @@ static void deallocBodyStats(void)
//#ifndef RESOURCE_NAMES
#if !defined (RESOURCE_NAMES) && !defined (STORE_RESOURCE_ID)
FREE(psStat->pName);
free(psStat->pName);
#endif
FREE(psStat->ppIMDList);
free(psStat->ppIMDList);
}
FREE(asBodyStats);
free(asBodyStats);
}
/*Deallocate all the stats assigned from input data*/
@ -426,7 +426,7 @@ BOOL loadWeaponStats(char *pWeaponData, UDWORD bufferSize)
//pData = pWeaponData;
psStats = &sStats;
/* psStats = (WEAPON_STATS *)MALLOC(sizeof(WEAPON_STATS));
/* psStats = (WEAPON_STATS *)malloc(sizeof(WEAPON_STATS));
if (psStats == NULL)
{
DBERROR(("Weapon Stats - Out of memory"));
@ -848,8 +848,8 @@ BOOL loadWeaponStats(char *pWeaponData, UDWORD bufferSize)
//increment the pointer to the start of the next record
pWeaponData = strchr(pWeaponData,'\n') + 1;
}
// FREE(pData);
// FREE(psStats);
// free(pData);
// free(psStats);
return TRUE;
}
@ -871,7 +871,7 @@ BOOL loadWeaponStats(char *pWeaponData, UDWORD bufferSize)
}
pStartArmourData = pArmourData;
psStats = (ARMOUR_STATS *)MALLOC(sizeof(ARMOUR_STATS));
psStats = (ARMOUR_STATS *)malloc(sizeof(ARMOUR_STATS));
if (psStats == NULL)
{
DBERROR(("Armour Stats - Out of memory"));
@ -914,7 +914,7 @@ BOOL loadWeaponStats(char *pWeaponData, UDWORD bufferSize)
&psStats->strength);
//allocate storage for the name
psStats->pName = (char *)MALLOC((strlen(ArmourName))+1);
psStats->pName = (char *)malloc((strlen(ArmourName))+1);
if (psStats->pName == NULL)
{
DBERROR(("Armour Stats Name - Out of memory"));
@ -931,8 +931,8 @@ BOOL loadWeaponStats(char *pWeaponData, UDWORD bufferSize)
//increment the pointer to the start of the next record
pArmourData = strchr(pArmourData,'\n') + 1;
}
FREE(pStartArmourData);
FREE(psStats);
free(pStartArmourData);
free(psStats);
return TRUE;
}
*/
@ -989,7 +989,7 @@ BOOL loadBodyStats(char *pBodyData, UDWORD bufferSize)
#endif
//allocate storage for the name
/*psStats->pName = (char *)MALLOC((strlen(BodyName))+1);
/*psStats->pName = (char *)malloc((strlen(BodyName))+1);
if (psStats->pName == NULL)
{
DBERROR(("Body Stats Name - Out of memory"));
@ -1189,7 +1189,7 @@ BOOL loadBrainStats(char *pBrainData, UDWORD bufferSize)
}
pStartPowerData = pPowerData;
psStats = (POWER_STATS *)MALLOC(sizeof(POWER_STATS));
psStats = (POWER_STATS *)malloc(sizeof(POWER_STATS));
if (psStats == NULL)
{
DBERROR(("Power Stats - Out of memory"));
@ -1232,7 +1232,7 @@ BOOL loadBrainStats(char *pBrainData, UDWORD bufferSize)
&psStats->output);
//allocate storage for the name
psStats->pName = (char *)MALLOC((strlen(PowerName))+1);
psStats->pName = (char *)malloc((strlen(PowerName))+1);
if (psStats->pName == NULL)
{
DBERROR(("Power Stats Name - Out of memory"));
@ -1249,8 +1249,8 @@ BOOL loadBrainStats(char *pBrainData, UDWORD bufferSize)
//increment the pointer to the start of the next record
pPowerData = strchr(pPowerData,'\n') + 1;
}
FREE(pStartPowerData);
FREE(psStats);
free(pStartPowerData);
free(psStats);
return TRUE;
}
*/
@ -1601,7 +1601,7 @@ BOOL loadECMStats(char *pECMData, UDWORD bufferSize)
//pData = pECMData;
psStats = &sStats;
/* psStats = (ECM_STATS *)MALLOC(sizeof(ECM_STATS));
/* psStats = (ECM_STATS *)malloc(sizeof(ECM_STATS));
if (psStats == NULL)
{
DBERROR(("ECM Stats - Out of memory"));
@ -1723,8 +1723,8 @@ BOOL loadECMStats(char *pECMData, UDWORD bufferSize)
//increment the pointer to the start of the next record
pECMData = strchr(pECMData,'\n') + 1;
}
// FREE(pData);
// FREE(psStats);
// free(pData);
// free(psStats);
return TRUE;
}
@ -1741,7 +1741,7 @@ BOOL loadRepairStats(char *pRepairData, UDWORD bufferSize)
//pData = pRepairData;
psStats = &sStats;
/* psStats = (REPAIR_STATS *)MALLOC(sizeof(REPAIR_STATS));
/* psStats = (REPAIR_STATS *)malloc(sizeof(REPAIR_STATS));
if (psStats == NULL)
{
DBERROR(("Repair Stats - Out of memory"));
@ -1870,8 +1870,8 @@ BOOL loadRepairStats(char *pRepairData, UDWORD bufferSize)
//increment the pointer to the start of the next record
pRepairData = strchr(pRepairData,'\n') + 1;
}
// FREE(pData);
// FREE(psStats);
// free(pData);
// free(psStats);
return TRUE;
}
@ -1888,7 +1888,7 @@ BOOL loadConstructStats(char *pConstructData, UDWORD bufferSize)
//pData = pConstructData;
psStats = &sStats;
/* psStats = (CONSTRUCT_STATS *)MALLOC(sizeof(CONSTRUCT_STATS));
/* psStats = (CONSTRUCT_STATS *)malloc(sizeof(CONSTRUCT_STATS));
if (psStats == NULL)
{
DBERROR(("Construct Stats - Out of memory"));
@ -1992,8 +1992,8 @@ BOOL loadConstructStats(char *pConstructData, UDWORD bufferSize)
//increment the pointer to the start of the next record
pConstructData = strchr(pConstructData,'\n') + 1;
}
// FREE(pData);
// FREE(psStats);
// free(pData);
// free(psStats);
return TRUE;
}
@ -2013,7 +2013,7 @@ BOOL loadPropulsionTypes(char *pPropTypeData, UDWORD bufferSize)
NumTypes = NUM_PROP_TYPES;
//allocate storage for the stats
asPropulsionTypes = (PROPULSION_TYPES *)MALLOC(sizeof(PROPULSION_TYPES)*NumTypes);
asPropulsionTypes = (PROPULSION_TYPES *)malloc(sizeof(PROPULSION_TYPES)*NumTypes);
if (asPropulsionTypes == NULL)
{
debug( LOG_ERROR, "PropulsionTypes - Out of memory" );
@ -2033,7 +2033,7 @@ BOOL loadPropulsionTypes(char *pPropTypeData, UDWORD bufferSize)
//allocate storage for the name
/*
asPropulsionTypes->pName = (char *)MALLOC((strlen(PropulsionName))+1);
asPropulsionTypes->pName = (char *)malloc((strlen(PropulsionName))+1);
if (asPropulsionTypes->pName == NULL)
{
DBERROR(("Propulsion Type Name - Out of memory"));
@ -2086,7 +2086,7 @@ BOOL loadPropulsionTypes(char *pPropTypeData, UDWORD bufferSize)
//increment the pointer to the start of the next record
pPropTypeData = strchr(pPropTypeData,'\n') + 1;
}
// FREE(pData);
// free(pData);
return TRUE;
}
@ -2106,7 +2106,7 @@ BOOL loadTerrainTable(char *pTerrainTableData, UDWORD bufferSize)
NumEntries = numCR(pTerrainTableData, bufferSize);
//allocate storage for the stats
asTerrainTable = (TERRAIN_TABLE *)MALLOC(sizeof(TERRAIN_TABLE) *
asTerrainTable = (TERRAIN_TABLE *)malloc(sizeof(TERRAIN_TABLE) *
//numPropulsionTypes * TERRAIN_TYPES);
NUM_PROP_TYPES * TERRAIN_TYPES);
@ -2142,7 +2142,7 @@ BOOL loadTerrainTable(char *pTerrainTableData, UDWORD bufferSize)
//increment the pointer to the start of the next record
pTerrainTableData = strchr(pTerrainTableData,'\n') + 1;
}
// FREE(pData);
// free(pData);
//check that none of the entries are 0 otherwise this will stop a droid dead in its tracks
//and it will not be able to move again!
@ -2177,7 +2177,7 @@ BOOL loadSpecialAbility(char *pSAbilityData, UDWORD bufferSize)
NumTypes = numCR(pSAbilityData, bufferSize);
//allocate storage for the stats
asSpecialAbility = (SPECIAL_ABILITY *)MALLOC(sizeof(SPECIAL_ABILITY)*NumTypes);
asSpecialAbility = (SPECIAL_ABILITY *)malloc(sizeof(SPECIAL_ABILITY)*NumTypes);
if (asSpecialAbility == NULL)
{
@ -2205,7 +2205,7 @@ BOOL loadSpecialAbility(char *pSAbilityData, UDWORD bufferSize)
return FALSE;
}
//allocate storage for the name
asSpecialAbility->pName = (char *)MALLOC((strlen(SAbilityName))+1);
asSpecialAbility->pName = (char *)malloc((strlen(SAbilityName))+1);
if (asSpecialAbility->pName == NULL)
{
debug( LOG_ERROR, "Special Ability Name - Out of memory" );
@ -2218,7 +2218,7 @@ BOOL loadSpecialAbility(char *pSAbilityData, UDWORD bufferSize)
pSAbilityData = strchr(pSAbilityData,'\n') + 1;
asSpecialAbility++;
}
// FREE(pData);
// free(pData);
//reset the pointer to the start of the special ability stats
asSpecialAbility = pSAbility;
@ -2249,7 +2249,7 @@ BOOL loadBodyPropulsionIMDs(char *pData, UDWORD bufferSize)
for (numStats = 0; numStats < numBodyStats; numStats++)
{
psBodyStat = &asBodyStats[numStats];
psBodyStat->ppIMDList = (iIMDShape **) MALLOC(numPropulsionStats *
psBodyStat->ppIMDList = (iIMDShape **) malloc(numPropulsionStats *
NUM_PROP_SIDES * sizeof(iIMDShape *));
if (psBodyStat->ppIMDList == NULL)
{
@ -2367,7 +2367,7 @@ BOOL loadBodyPropulsionIMDs(char *pData, UDWORD bufferSize)
//increment the pointer to the start of the next record
pData = strchr(pData,'\n') + 1;
}
// FREE(pStartData);
// free(pStartData);
return(TRUE);
}
@ -2841,16 +2841,16 @@ void deallocPropulsionTypes(void)
/*
for (inc=0; inc < numPropulsionTypes; inc++, pList++)
{
FREE(pList->pName);
free(pList->pName);
}
*/
FREE (asPropulsionTypes);
free(asPropulsionTypes);
}
//dealloc the storage assigned for the terrain table
void deallocTerrainTable(void)
{
FREE(asTerrainTable);
free(asTerrainTable);
}
//dealloc the storage assigned for the Special Ability stats
@ -2861,9 +2861,9 @@ void deallocSpecialAbility(void)
for (inc=0; inc < numSpecialAbility; inc++, pList++)
{
FREE(pList->pName);
free(pList->pName);
}
FREE (asSpecialAbility);
free(asSpecialAbility);
}
//store the speed Factor in the terrain table
@ -3544,7 +3544,7 @@ BOOL allocateName(char **ppStore, char *pName)
#else
//need to allocate space for the name
*ppStore = (char *)MALLOC((strlen(pName))+1);
*ppStore = (char *)malloc((strlen(pName))+1);
if (ppStore == NULL)
{
debug( LOG_ERROR, "Name - Out of memory" );

View File

@ -800,11 +800,11 @@ BOOL loadStructureStats(char *pStructData, UDWORD bufferSize)
NumStructures = numCR(pStructData, bufferSize);
//#ifdef DEMO
// asStructureStats = (STRUCTURE_STATS *)MALLOC(sizeof(STRUCTURE_STATS)*
// asStructureStats = (STRUCTURE_STATS *)malloc(sizeof(STRUCTURE_STATS)*
// (NumStructures + NUM_DEMO_STRUCTS));
// //numStructureStats is added to in in demoStructs()
//#else
asStructureStats = (STRUCTURE_STATS *)MALLOC(sizeof(STRUCTURE_STATS)*
asStructureStats = (STRUCTURE_STATS *)malloc(sizeof(STRUCTURE_STATS)*
NumStructures);
//#endif
numStructureStats = NumStructures;
@ -872,7 +872,7 @@ BOOL loadStructureStats(char *pStructData, UDWORD bufferSize)
//#endif
//allocate storage for the name
/*psStructure->pName = (char *)MALLOC((strlen(StructureName))+1);
/*psStructure->pName = (char *)malloc((strlen(StructureName))+1);
if (psStructure->pName == NULL)
{
DBERROR(("Structure Stats Name - Out of memory"));
@ -1009,9 +1009,9 @@ BOOL loadStructureStats(char *pStructData, UDWORD bufferSize)
//if (psStructure->numWeaps > 0)
/*if (numWeaps > 0)
{
//psStructure->asWeapList = (WEAPON_STATS **)MALLOC(psStructure->weaponSlots*
//psStructure->asWeapList = (WEAPON_STATS **)malloc(psStructure->weaponSlots*
// sizeof(WEAPON_STATS*));
psStructure->asWeapList = (WEAPON_STATS **)MALLOC(numWeaps *
psStructure->asWeapList = (WEAPON_STATS **)malloc(numWeaps *
sizeof(WEAPON_STATS*));
if (psStructure->asWeapList == NULL)
{
@ -1023,7 +1023,7 @@ BOOL loadStructureStats(char *pStructData, UDWORD bufferSize)
psStructure->defaultFunc = -1;
if (psStructure->numFuncs > 0)
{
psStructure->asFuncList = (FUNCTION **)MALLOC(psStructure->numFuncs*
psStructure->asFuncList = (FUNCTION **)malloc(psStructure->numFuncs*
sizeof(FUNCTION*));
if (psStructure->asFuncList == NULL)
{
@ -1038,7 +1038,7 @@ BOOL loadStructureStats(char *pStructData, UDWORD bufferSize)
psStructure++;
}
// FREE(pData);
// free(pData);
asStructureStats = pStartStats;
@ -1071,7 +1071,7 @@ BOOL loadStructureStats(char *pStructData, UDWORD bufferSize)
//allocate the structureLimits structure
for (player = 0; player < MAX_PLAYERS; player++)
{
asStructLimits[player] = (STRUCTURE_LIMITS *)MALLOC (sizeof(STRUCTURE_LIMITS) *
asStructLimits[player] = (STRUCTURE_LIMITS *)malloc(sizeof(STRUCTURE_LIMITS) *
numStructureStats);
if (asStructLimits[player] == NULL)
{
@ -1262,7 +1262,7 @@ BOOL loadStructureWeapons(char *pWeaponData, UDWORD bufferSize)
//increment the pointer to the start of the next record
pWeaponData = strchr(pWeaponData,'\n') + 1;
}
// FREE(pStartWeaponData);
// free(pStartWeaponData);
return TRUE;
}
@ -1346,7 +1346,7 @@ BOOL loadStructureFunctions(char *pFunctionData, UDWORD bufferSize)
//increment the pointer to the start of the next record
pFunctionData = strchr(pFunctionData,'\n') + 1;
}
// FREE(pStartFunctionData);
// free(pStartFunctionData);
/**************************************************************************/
//Wall Function requires a structure stat so can allocate it now
@ -1454,27 +1454,27 @@ BOOL structureStatsShutDown(void)
{
//#ifndef RESOURCE_NAMES
#if !defined (RESOURCE_NAMES) && !defined (STORE_RESOURCE_ID)
FREE(pStructure->pName);
free(pStructure->pName);
#endif
/*if (pStructure->numWeaps > 0)
{
FREE(pStructure->asWeapList);
free(pStructure->asWeapList);
}*/
if (pStructure->numFuncs > 0)
{
FREE(pStructure->asFuncList);
free(pStructure->asFuncList);
}
}
if(numStructureStats) {
FREE(asStructureStats);
free(asStructureStats);
}
//free up the structLimits structure
for (inc = 0; inc < MAX_PLAYERS ; inc++)
{
if(asStructLimits[inc]) {
FREE(asStructLimits[inc]);
free(asStructLimits[inc]);
}
}
@ -2763,7 +2763,7 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType)
return FALSE;
}
//allocate the necessary space
/*psBuilding->pFunctionality = (FUNCTIONALITY *) MALLOC(sizeof(FACTORY));
/*psBuilding->pFunctionality = (FUNCTIONALITY *) malloc(sizeof(FACTORY));
if (psBuilding->pFunctionality == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -2882,7 +2882,7 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType)
return FALSE;
}
//allocate the necessary space
/*psBuilding->pFunctionality = (FUNCTIONALITY *) MALLOC(sizeof(RESEARCH_FACILITY));
/*psBuilding->pFunctionality = (FUNCTIONALITY *) malloc(sizeof(RESEARCH_FACILITY));
if (psBuilding->pFunctionality == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -2948,7 +2948,7 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType)
return FALSE;
}
//allocate the necessary space
/*psBuilding->pFunctionality = (FUNCTIONALITY *) MALLOC(sizeof(POWER_GEN));
/*psBuilding->pFunctionality = (FUNCTIONALITY *) malloc(sizeof(POWER_GEN));
if (psBuilding->pFunctionality == NULL)
{
DBERROR(("Out of memory"));
@ -2985,7 +2985,7 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType)
return FALSE;
}
//allocate the necessary space
/*psBuilding->pFunctionality = (FUNCTIONALITY *) MALLOC(sizeof(RES_EXTRACTOR));
/*psBuilding->pFunctionality = (FUNCTIONALITY *) malloc(sizeof(RES_EXTRACTOR));
if (psBuilding->pFunctionality == NULL)
{
DBERROR(("Out of memory"));
@ -3049,7 +3049,7 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType)
}
//allocate the necessary space
/*psBuilding->pFunctionality = (FUNCTIONALITY *) MALLOC(sizeof(REPAIR_FACILITY));
/*psBuilding->pFunctionality = (FUNCTIONALITY *) malloc(sizeof(REPAIR_FACILITY));
if (psBuilding->pFunctionality == NULL)
{
debug( LOG_ERROR, "Out of memory" );
@ -3096,7 +3096,7 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType)
//getNearestBestValidTile(&x,&y);
setAssemblyPoint( psRepairFac->psDeliveryPoint, x << TILE_SHIFT,
y << TILE_SHIFT, psBuilding->player, TRUE);
addFlagPosition(psRepairFac->psDeliveryPoint);
setFlagPositionInc(psRepairFac, psBuilding->player, REPAIR_FLAG);
break;
@ -10049,7 +10049,7 @@ BOOL createStructureStat(STRUCTURE_STATS *psBuilding, STRUCTURE_STATS *psNewStru
psNewStructure->type = type;
//allocate storage for the name
psNewStructure->pName = (char *) MALLOC(MAX_NAME_SIZE);
psNewStructure->pName = (char *) malloc(MAX_NAME_SIZE);
if (psNewStructure->pName == NULL)
{
DBERROR(("Structure Stats Name - Out of memory"));
@ -10060,7 +10060,7 @@ BOOL createStructureStat(STRUCTURE_STATS *psBuilding, STRUCTURE_STATS *psNewStru
//allocate storage for the weapons and functions - if any
if (psNewStructure->numWeaps > 0)
{
psNewStructure->asWeapList = (WEAPON_STATS **)MALLOC(psNewStructure->
psNewStructure->asWeapList = (WEAPON_STATS **)malloc(psNewStructure->
weaponSlots * sizeof(WEAPON_STATS*));
if (psNewStructure->asWeapList == NULL)
{
@ -10076,7 +10076,7 @@ BOOL createStructureStat(STRUCTURE_STATS *psBuilding, STRUCTURE_STATS *psNewStru
//allocate storage for the functions - if any
if (psNewStructure->numFuncs > 0)
{
psNewStructure->asFuncList = (FUNCTION **)MALLOC(psNewStructure->
psNewStructure->asFuncList = (FUNCTION **)malloc(psNewStructure->
numFuncs * sizeof(FUNCTION*));
if (psNewStructure->asFuncList == NULL)
{

View File

@ -90,8 +90,8 @@ void makeTileTexturePages(UDWORD srcWidth, UDWORD srcHeight, UDWORD tileWidth, U
/* Get enough memory to store one tile */
pageNumber = 0;
tileStorage = (char*)MALLOC(tileWidth * tileHeight * PAGE_DEPTH);
sprite.bmp = (iBitmap*)MALLOC(TEXTURE_PAGE_SIZE);
tileStorage = (char*)malloc(tileWidth * tileHeight * PAGE_DEPTH);
sprite.bmp = (iBitmap*)malloc(TEXTURE_PAGE_SIZE);
sprite.width = PAGE_WIDTH;
sprite.height = PAGE_HEIGHT;
tilesProcessed = 0;
@ -127,7 +127,7 @@ void makeTileTexturePages(UDWORD srcWidth, UDWORD srcHeight, UDWORD tileWidth, U
tilesDown, tilesAcross, tilesProcessed, tilesPerPage);
/* If so, download this one and reset to start again */
pageId[pageNumber] = pie_AddBMPtoTexPages(&sprite, "terrain", 0, FALSE);
sprite.bmp = (iBitmap*)MALLOC(TEXTURE_PAGE_SIZE);
sprite.bmp = (iBitmap*)malloc(TEXTURE_PAGE_SIZE);
pageNumber++;
presentLoc = sprite.bmp;
}
@ -143,7 +143,7 @@ void makeTileTexturePages(UDWORD srcWidth, UDWORD srcHeight, UDWORD tileWidth, U
ASSERT(FALSE, "we should have exited the loop using the goto");
exit:
numTexturePages = pageNumber+1;
FREE(tileStorage);
free(tileStorage);
buildTileIndexes();
return;
}
@ -165,11 +165,11 @@ void remakeTileTexturePages(UDWORD srcWidth,UDWORD srcHeight, UDWORD tileWidth,
/* Get enough memory to store one tile */
pageNumber = 0;
tileStorage = (char*)MALLOC(tileWidth * tileHeight * PAGE_DEPTH);
tileStorage = (char*)malloc(tileWidth * tileHeight * PAGE_DEPTH);
sprite.width = PAGE_WIDTH;
sprite.height = PAGE_HEIGHT;
sprite.bmp = (iBitmap*)MALLOC(TEXTURE_PAGE_SIZE);
sprite.bmp = (iBitmap*)malloc(TEXTURE_PAGE_SIZE);
// memset(sprite.bmp,0,TEXTURE_PAGE_SIZE);
tilesProcessed = 0;
tilesAcross = srcWidth/tileWidth;
@ -220,7 +220,7 @@ void remakeTileTexturePages(UDWORD srcWidth,UDWORD srcHeight, UDWORD tileWidth,
ASSERT( numTexturePages >= (SDWORD)pageNumber,"New Tertiles too large" );
exit:
FREE(tileStorage);
free(tileStorage);
buildTileIndexes();
return;
}
@ -271,7 +271,7 @@ void freeTileTextures(void)
for (i = 0; i < numTexturePages; i++)
{
FREE(_TEX_PAGE[(firstTexturePage+i)].tex.bmp);
free(_TEX_PAGE[(firstTexturePage+i)].tex.bmp);
}
}