Prevent GCC from turning PRAM_Zalloc into PRAM_Malloc + memset
This commit is contained in:
parent
f4c33a2b6a
commit
7d5a81d375
|
@ -91,8 +91,8 @@ void CGD_PRAM_Free(void *ptr)
|
|||
|
||||
void *CGD_PRAM_Zalloc(size_t size)
|
||||
{
|
||||
uint32_t *ptr = CGD_PRAM_Malloc(size);
|
||||
uint32_t volatile *ptr = CGD_PRAM_Malloc(size);
|
||||
if(!ptr) return NULL;
|
||||
for(int i = 0; i < size / 4; i++) ptr[i] = 0;
|
||||
return ptr;
|
||||
return (void *)ptr;
|
||||
}
|
||||
|
|
|
@ -60,9 +60,9 @@
|
|||
|
||||
// Location of each lump on disk.
|
||||
lumpinfo_t* lumpinfo;
|
||||
static int numlumps;
|
||||
static int numlumps = 0;
|
||||
|
||||
void** lumpcache;
|
||||
void** lumpcache = NULL;
|
||||
|
||||
|
||||
//
|
||||
|
@ -157,12 +157,15 @@ static int W_AddFile ()
|
|||
//
|
||||
int W_InitMultipleFiles(void)
|
||||
{
|
||||
int previous_numlumps = numlumps;
|
||||
|
||||
// open all the files, load headers, and count lumps
|
||||
numlumps = 0;
|
||||
|
||||
/* CGDoom: Loading multiples files hasn't been tested for a long time and may
|
||||
not work due to the allocation of lumpcache */
|
||||
|
||||
// will be realloced as lumps are added
|
||||
//lumpinfo = (lumpinfo_t*)CGDMalloc(1);
|
||||
//CGD: CGDrealloc accepts NULL
|
||||
lumpinfo = NULL;
|
||||
if(!W_AddFile ())
|
||||
{
|
||||
|
@ -176,7 +179,12 @@ int W_InitMultipleFiles(void)
|
|||
|
||||
// set up caching
|
||||
//printf ("numlumps = %i \n",numlumps);
|
||||
lumpcache = (void **)CGD_PRAM_Zalloc(numlumps * sizeof(*lumpcache));
|
||||
if (lumpcache != NULL && numlumps <= previous_numlumps) {
|
||||
/* Don't realloc when not needed */
|
||||
}
|
||||
else {
|
||||
lumpcache = (void **)CGD_PRAM_Zalloc(numlumps * sizeof(*lumpcache));
|
||||
}
|
||||
|
||||
if (!lumpcache)
|
||||
{
|
||||
|
|
|
@ -470,7 +470,7 @@ void Z_ChangeTag2(const void* ptr,int tag )
|
|||
|
||||
if (block->id != ZONEID)
|
||||
{
|
||||
I_Error ("Z_ChangeTag: freed a pointer without ZONEID");
|
||||
I_ErrorI ("Z_ChangeTag: freed a pointer without ZONEID", (int)ptr, 0, 0, 0);
|
||||
}
|
||||
|
||||
if (tag >= PU_PURGELEVEL && (unsigned)block->user < 0x100)
|
||||
|
|
Loading…
Reference in New Issue