mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 19:20:46 +00:00
SW: Run all allocations through Xmalloc et al
git-svn-id: https://svn.eduke32.com/eduke32@8515 1a8010ca-5511-0410-912e-c29ae57300e0 # Conflicts: # source/audiolib/src/driver_winmm.cpp # source/audiolib/src/flac.cpp # source/sw/src/StartupWinController.game.mm # source/sw/src/bldscript.cpp # source/sw/src/game.cpp # source/sw/src/game.h # source/sw/src/grpscan.cpp # source/sw/src/jbhlp.cpp # source/sw/src/rts.cpp # source/sw/src/scrip2.cpp # source/sw/src/sounds.cpp
This commit is contained in:
parent
e9602e0e74
commit
846c7eaff2
2 changed files with 19 additions and 44 deletions
|
@ -443,12 +443,19 @@ AllocMem(int size)
|
||||||
void *
|
void *
|
||||||
ReAllocMem(void *ptr, int size)
|
ReAllocMem(void *ptr, int size)
|
||||||
{
|
{
|
||||||
|
if (ptr == nullptr)
|
||||||
|
return AllocMem(size);
|
||||||
|
|
||||||
|
if (size == 0)
|
||||||
|
{
|
||||||
|
FreeMem(ptr);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t* bp;
|
uint8_t* bp;
|
||||||
MEM_HDRp mhp;
|
MEM_HDRp mhp;
|
||||||
uint8_t* check;
|
uint8_t* check;
|
||||||
|
|
||||||
ASSERT(size != 0);
|
|
||||||
|
|
||||||
ASSERT(ValidPtr(ptr));
|
ASSERT(ValidPtr(ptr));
|
||||||
|
|
||||||
mhp = (MEM_HDRp)(((uint8_t*) ptr) - sizeof(MEM_HDR));
|
mhp = (MEM_HDRp)(((uint8_t*) ptr) - sizeof(MEM_HDR));
|
||||||
|
@ -506,11 +513,12 @@ CallocMem(int size, int num)
|
||||||
void
|
void
|
||||||
FreeMem(void *ptr)
|
FreeMem(void *ptr)
|
||||||
{
|
{
|
||||||
|
if (ptr == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
MEM_HDRp mhp;
|
MEM_HDRp mhp;
|
||||||
uint8_t* check;
|
uint8_t* check;
|
||||||
|
|
||||||
ASSERT(ptr != NULL);
|
|
||||||
|
|
||||||
ASSERT(ValidPtr(ptr));
|
ASSERT(ValidPtr(ptr));
|
||||||
|
|
||||||
mhp = (MEM_HDRp)(((uint8_t*) ptr) - sizeof(MEM_HDR));
|
mhp = (MEM_HDRp)(((uint8_t*) ptr) - sizeof(MEM_HDR));
|
||||||
|
@ -521,39 +529,6 @@ FreeMem(void *ptr)
|
||||||
free(mhp);
|
free(mhp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
SWBOOL
|
|
||||||
ValidPtr(void *ptr)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
void *
|
|
||||||
AllocMem(int size)
|
|
||||||
{
|
|
||||||
return malloc(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
CallocMem(int size, int num)
|
|
||||||
{
|
|
||||||
return calloc(size, num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
ReAllocMem(void *ptr, int size)
|
|
||||||
{
|
|
||||||
return realloc(ptr, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
FreeMem(void *ptr)
|
|
||||||
{
|
|
||||||
free(ptr);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int PointOnLine(int x, int y, int x1, int y1, int x2, int y2)
|
int PointOnLine(int x, int y, int x1, int y1, int x2, int y2)
|
||||||
|
|
|
@ -1754,18 +1754,18 @@ typedef struct
|
||||||
unsigned int size, checksum;
|
unsigned int size, checksum;
|
||||||
} MEM_HDR,*MEM_HDRp;
|
} MEM_HDR,*MEM_HDRp;
|
||||||
|
|
||||||
|
#if !DEBUG
|
||||||
|
# define ValidPtr(ptr) ((SWBOOL)(TRUE))
|
||||||
|
# define AllocMem(size) Xmalloc(size)
|
||||||
|
# define CallocMem(size, num) Xcalloc(size, num)
|
||||||
|
# define ReAllocMem(ptr, size) Xrealloc(ptr, size)
|
||||||
|
# define FreeMem(ptr) Xfree(ptr)
|
||||||
|
#else
|
||||||
SWBOOL ValidPtr(void *ptr);
|
SWBOOL ValidPtr(void *ptr);
|
||||||
#if 0
|
|
||||||
void *AllocMem(int size);
|
void *AllocMem(int size);
|
||||||
void *CallocMem(int size, int num);
|
void *CallocMem(int size, int num);
|
||||||
void *ReAllocMem(void *ptr, int size);
|
void *ReAllocMem(void *ptr, int size);
|
||||||
void FreeMem(void *ptr);
|
void FreeMem(void *ptr);
|
||||||
#else
|
|
||||||
// Make these #defines so that MSVC's allocation tracker gets correct line numbers
|
|
||||||
#define AllocMem malloc
|
|
||||||
#define CallocMem calloc
|
|
||||||
#define ReAllocMem realloc
|
|
||||||
#define FreeMem free
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
Loading…
Reference in a new issue