diff --git a/GRRLIB/GRRLIB/GRRLIB_core.c b/GRRLIB/GRRLIB/GRRLIB_core.c index bdeb045..49eba09 100644 --- a/GRRLIB/GRRLIB/GRRLIB_core.c +++ b/GRRLIB/GRRLIB/GRRLIB_core.c @@ -165,6 +165,6 @@ void GRRLIB_Exit (void) { // Free up memory allocated for frame buffers & FIFOs 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; } } diff --git a/GRRLIB/GRRLIB/grrlib/GRRLIB_texSetup.h b/GRRLIB/GRRLIB/grrlib/GRRLIB_texSetup.h index 134cf43..01842d0 100644 --- a/GRRLIB/GRRLIB/grrlib/GRRLIB_texSetup.h +++ b/GRRLIB/GRRLIB/grrlib/GRRLIB_texSetup.h @@ -49,7 +49,7 @@ GRRLIB_texImg* GRRLIB_CreateEmptyTexture (const uint w, const uint h) my_texture->h = h; // 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_FlushTex(my_texture); @@ -73,20 +73,20 @@ void GRRLIB_FlushTex (GRRLIB_texImg *tex) { */ INLINE void GRRLIB_FreeTexture (GRRLIB_texImg *tex) { - free(tex->data); - free(tex); - tex = NULL; + if(tex != NULL) { + free(tex->data); + free(tex); + tex = NULL; + } } -//============================================================================== /** - * Clear a texture to transparent black - * @param tex : Texture to clear + * Clear a texture to transparent black. + * @param tex Texture to clear. */ -//============================================================================== INLINE 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); }