Remove the allocache() allocation type for 'intptr_t *lookups'.

Always malloc that buffer.  This allows us to remove suckcache() from
cache1d.c, which I believe to be buggy (see comments in the source).

git-svn-id: https://svn.eduke32.com/eduke32@2261 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-01-15 22:39:59 +00:00
parent 260bbc1f92
commit 031da6280d
3 changed files with 13 additions and 15 deletions

View file

@ -17,7 +17,7 @@ extern char filegrp[MAXOPENFILES];
void initcache(intptr_t dacachestart, int32_t dacachesize);
void allocache(intptr_t *newhandle, int32_t newbytes, char *newlockptr);
void suckcache(intptr_t *suckptr);
//void suckcache(intptr_t *suckptr);
void agecache(void);
extern int32_t pathsearchmode; // 0 = gamefs mode (default), 1 = localfs mode (editor's mode)

View file

@ -181,6 +181,7 @@ void allocache(intptr_t *newhandle, int32_t newbytes, char *newlockptr)
cac[bestz].lock = &zerochar;
}
#if 0
void suckcache(intptr_t *suckptr)
{
int32_t i;
@ -198,16 +199,17 @@ void suckcache(intptr_t *suckptr)
if ((i > 0) && (*cac[i-1].lock == 0))
{
cac[i-1].leng += cac[i].leng;
cacnum--; copybuf(&cac[i+1],&cac[i],(cacnum-i)*sizeof(cactype));
cacnum--; copybuf(&cac[i+1],&cac[i],(cacnum-i)*sizeof(cactype)); // XXX: this looks suspicious, copybuf already multiplies by 4...
}
else if ((i < cacnum-1) && (*cac[i+1].lock == 0))
{
cac[i+1].leng += cac[i].leng;
cacnum--; copybuf(&cac[i+1],&cac[i],(cacnum-i)*sizeof(cactype));
cacnum--; copybuf(&cac[i+1],&cac[i],(cacnum-i)*sizeof(cactype)); // XXX: see above
}
}
}
}
#endif
void agecache(void)
{

View file

@ -97,7 +97,6 @@ static int32_t lowrecip[1024], nytooclose, nytoofar;
static uint32_t distrecip[65536+256];
static intptr_t *lookups = NULL;
static char lookupsalloctype = 255;
int32_t dommxoverlay = 1, beforedrawrooms = 1, indrawroomsandmasks = 0;
static int32_t oxdimen = -1, oviewingrange = -1, oxyaspect = -1;
@ -7883,8 +7882,7 @@ void uninitengine(void)
if (pic != NULL) { Bfree(pic); pic = NULL; }
if (lookups != NULL)
{
if (lookupsalloctype == 0) Bfree((void *)lookups);
//if (lookupsalloctype == 1) suckcache(lookups); //Cache already gone
Bfree((void *)lookups);
lookups = NULL;
}
@ -10061,16 +10059,14 @@ int32_t setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t da
j = ydim*4*sizeof(intptr_t); //Leave room for horizlookup&horizlookup2
if (lookups != NULL)
Bfree((void *)lookups);
lookups = Bmalloc(j<<1);
if (lookups == NULL)
{
if (lookupsalloctype == 0) Bfree((void *)lookups);
if (lookupsalloctype == 1) suckcache(lookups);
lookups = NULL;
}
lookupsalloctype = 0;
if ((lookups = (intptr_t *)Bmalloc(j<<1)) == NULL)
{
allocache((intptr_t *)&lookups,j<<1,&permanentlock);
lookupsalloctype = 1;
initprintf("OUT OF MEMORY in setgamemode!\n");
uninitengine();
exit(1);
}
horizlookup = lookups;