Switch palookup memory allocation to Xalligned_alloc and fix what looks like a botched preprocessor condition

git-svn-id: https://svn.eduke32.com/eduke32@6438 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2017-09-19 19:10:19 +00:00
parent c7d2f0b869
commit 29fc836bb1
2 changed files with 5 additions and 8 deletions

View File

@ -7806,7 +7806,7 @@ void uninitengine(void)
if (i==0 || palookup[i] != palookup[0])
{
// Take care of handling aliased ^^^ cases!
Bfree(palookup[i]);
Baligned_free(palookup[i]);
}
Bmemset(palookup, 0, sizeof(palookup));

View File

@ -87,14 +87,11 @@ void setup_blend(int32_t blend, int32_t doreverse)
static void alloc_palookup(int32_t pal)
{
#if defined ENGINE_USING_A_C || (defined CLASSIC_NONPOW2_YSIZE_WALLS && defined CLASSIC_NONPOW2_YSIZE_SPRITES)
palookup[pal] = (char *) Xmalloc(numshades*256);
#else
// The asm functions vlineasm1, mvlineasm1 (maybe others?) access the next
// palookup[...] shade entry for tilesizy==512 tiles.
// See DEBUG_TILESIZY_512 and the comment in a.nasm: vlineasm1.
palookup[pal] = (char *) Xcalloc(numshades+1, 256);
#endif
palookup[pal] = (char *) Xaligned_alloc(16, (numshades + 1) * 256);
memset(palookup[pal], 0, (numshades + 1) * 256);
}
static void maybe_alloc_palookup(int32_t palnum);
@ -518,12 +515,12 @@ void removepalookup(int32_t const palnum)
if (palookup[i] == palookup[palnum])
palookup[i] = NULL;
DO_FREE_AND_NULL(palookup[palnum]);
ALIGNED_FREE_AND_NULL(palookup[palnum]);
}
else if (palookup[palnum] == palookup[0])
palookup[palnum] = NULL;
else
DO_FREE_AND_NULL(palookup[palnum]);
ALIGNED_FREE_AND_NULL(palookup[palnum]);
}
//