mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 23:12:21 +00:00
[CHG] Make sure a NULL pointer is not free'd
This commit is contained in:
parent
c8abda9052
commit
34a1991cd9
2 changed files with 10 additions and 10 deletions
|
@ -165,6 +165,6 @@ void GRRLIB_Exit (void) {
|
||||||
|
|
||||||
// Free up memory allocated for frame buffers & FIFOs
|
// Free up memory allocated for frame buffers & FIFOs
|
||||||
if (xfb[0] != NULL) { free(MEM_K1_TO_K0(xfb[0])); xfb[0] = NULL; }
|
if (xfb[0] != NULL) { free(MEM_K1_TO_K0(xfb[0])); xfb[0] = NULL; }
|
||||||
if (xfb[1] != NULL) { free(MEM_K1_TO_K0(xfb[1])); xfb[0] = NULL; }
|
if (xfb[1] != NULL) { free(MEM_K1_TO_K0(xfb[1])); xfb[1] = NULL; }
|
||||||
if (gp_fifo != NULL) { free(gp_fifo); gp_fifo = NULL; }
|
if (gp_fifo != NULL) { free(gp_fifo); gp_fifo = NULL; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ GRRLIB_texImg* GRRLIB_CreateEmptyTexture (const uint w, const uint h)
|
||||||
my_texture->h = h;
|
my_texture->h = h;
|
||||||
|
|
||||||
// Initialize the texture
|
// Initialize the texture
|
||||||
memset(my_texture->data, '\0', (h * w) << 2);
|
memset(my_texture->data, '\0', (h * w) << 2);
|
||||||
|
|
||||||
GRRLIB_SetHandle(my_texture, 0, 0);
|
GRRLIB_SetHandle(my_texture, 0, 0);
|
||||||
GRRLIB_FlushTex(my_texture);
|
GRRLIB_FlushTex(my_texture);
|
||||||
|
@ -73,20 +73,20 @@ void GRRLIB_FlushTex (GRRLIB_texImg *tex) {
|
||||||
*/
|
*/
|
||||||
INLINE
|
INLINE
|
||||||
void GRRLIB_FreeTexture (GRRLIB_texImg *tex) {
|
void GRRLIB_FreeTexture (GRRLIB_texImg *tex) {
|
||||||
free(tex->data);
|
if(tex != NULL) {
|
||||||
free(tex);
|
free(tex->data);
|
||||||
tex = NULL;
|
free(tex);
|
||||||
|
tex = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
/**
|
/**
|
||||||
* Clear a texture to transparent black
|
* Clear a texture to transparent black.
|
||||||
* @param tex : Texture to clear
|
* @param tex Texture to clear.
|
||||||
*/
|
*/
|
||||||
//==============================================================================
|
|
||||||
INLINE
|
INLINE
|
||||||
void GRRLIB_ClearTex(GRRLIB_texImg* tex)
|
void GRRLIB_ClearTex(GRRLIB_texImg* tex)
|
||||||
{
|
{
|
||||||
bzero(tex->data, (tex->h *tex->w) <<2);
|
bzero(tex->data, (tex->h * tex->w) << 2);
|
||||||
GRRLIB_FlushTex(tex);
|
GRRLIB_FlushTex(tex);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue