Cleanup FreeMipmapColormap
This commit is contained in:
parent
5ba363fda6
commit
e9e0683d5e
|
@ -776,22 +776,36 @@ static void FreeMipmapColormap(INT32 patchnum, void *patch)
|
||||||
{
|
{
|
||||||
GLPatch_t* const pat = patch;
|
GLPatch_t* const pat = patch;
|
||||||
(void)patchnum; //unused
|
(void)patchnum; //unused
|
||||||
while (pat->mipmap && pat->mipmap->nextcolormap) // The mipmap must be valid, obviously
|
|
||||||
|
// The patch must be valid, obviously
|
||||||
|
if (!pat)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// The mipmap must be valid, obviously
|
||||||
|
while (pat->mipmap)
|
||||||
{
|
{
|
||||||
// Confusing at first, but pat->mipmap->nextcolormap
|
// Confusing at first, but pat->mipmap->nextcolormap
|
||||||
// at the beginning of the loop is the first colormap
|
// at the beginning of the loop is the first colormap
|
||||||
// from the linked list of colormaps
|
// from the linked list of colormaps.
|
||||||
GLMipmap_t *next = pat->mipmap;
|
GLMipmap_t *next = NULL;
|
||||||
if (!next) // No mipmap in this patch, break out of loop.
|
|
||||||
|
// No mipmap in this patch, break out of the loop.
|
||||||
|
if (!pat->mipmap)
|
||||||
break;
|
break;
|
||||||
// Set the first colormap
|
|
||||||
// to the one that comes after it
|
// No colormap mipmap either.
|
||||||
next = next->nextcolormap;
|
if (!pat->mipmap->nextcolormap)
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Set the first colormap to the one that comes after it.
|
||||||
|
next = pat->mipmap->nextcolormap;
|
||||||
pat->mipmap->nextcolormap = next->nextcolormap;
|
pat->mipmap->nextcolormap = next->nextcolormap;
|
||||||
// Free image data from memory
|
|
||||||
|
// Free image data from memory.
|
||||||
if (next->grInfo.data)
|
if (next->grInfo.data)
|
||||||
Z_Free(next->grInfo.data);
|
Z_Free(next->grInfo.data);
|
||||||
// Free the old colormap from memory
|
|
||||||
|
// Free the old colormap from memory.
|
||||||
free(next);
|
free(next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue