Correct cppcheck warnings

This commit is contained in:
Crayon2000 2017-06-14 00:02:41 -04:00
parent d18e3d710c
commit d48d7b8819
4 changed files with 19 additions and 18 deletions

View file

@ -80,20 +80,21 @@ GRRLIB_bytemapFont* GRRLIB_LoadBMF (const u8 my_bmf[] ) {
/**
* Free memory allocated by ByteMap fonts.
* If \a bmf is a null pointer, the function does nothing.
* @note This function does not change the value of \a bmf itself, hence it still points to the same (now invalid) location.
* @param bmf A GRRLIB_bytemapFont structure.
*/
void GRRLIB_FreeBMF (GRRLIB_bytemapFont *bmf) {
u16 i;
for (i=0; i<256; i++) {
if (bmf->charDef[i].data != NULL) {
free(bmf->charDef[i].data);
if (bmf != NULL) {
for (u16 i=0; i<256; i++) {
if (bmf->charDef[i].data != NULL) {
free(bmf->charDef[i].data);
}
}
free(bmf->palette);
free(bmf->name);
free(bmf);
}
free(bmf->palette);
free(bmf->name);
free(bmf);
bmf = NULL;
}
/**

View file

@ -67,19 +67,17 @@ void GRRLIB_BMFX_FlipV (const GRRLIB_texImg *texsrc, GRRLIB_texImg *texdest) {
void GRRLIB_BMFX_Grayscale (const GRRLIB_texImg *texsrc,
GRRLIB_texImg *texdest) {
unsigned int x, y;
u8 gray;
u32 color;
for (y = 0; y < texsrc->h; y++) {
for (x = 0; x < texsrc->w; x++) {
color = GRRLIB_GetPixelFromtexImg(x, y, texsrc);
u32 color = GRRLIB_GetPixelFromtexImg(x, y, texsrc);
gray = ((R(color)* 77 +
G(color)*150 +
B(color)* 28 ) / 255);
u8 gray = ((R(color)* 77 +
G(color)*150 +
B(color)* 28 ) / 255);
GRRLIB_SetPixelTotexImg(x, y, texdest,
((gray << 24) | (gray << 16) | (gray << 8) | A(color)));
(gray << 24) | (gray << 16) | (gray << 8) | (A(color)));
}
}
GRRLIB_SetHandle(texdest, 0, 0);

View file

@ -75,13 +75,14 @@ GRRLIB_ttfFont* GRRLIB_LoadTTF (const u8* file_base, s32 file_size) {
/**
* Free memory allocated by TTF fonts.
* If \a myFont is a null pointer, the function does nothing.
* @note This function does not change the value of \a myFont itself, hence it still points to the same (now invalid) location.
* @param myFont A TTF.
*/
void GRRLIB_FreeTTF (GRRLIB_ttfFont *myFont) {
if (myFont != NULL) {
FT_Done_Face(myFont->face);
free(myFont);
myFont = NULL;
}
}

View file

@ -41,6 +41,8 @@ void GRRLIB_FlushTex (GRRLIB_texImg *tex) {
/**
* Free memory allocated for texture.
* If \a tex is a null pointer, the function does nothing.
* @note This function does not change the value of \a tex itself, hence it still points to the same (now invalid) location.
* @param tex A GRRLIB_texImg structure.
*/
INLINE
@ -50,7 +52,6 @@ void GRRLIB_FreeTexture (GRRLIB_texImg *tex) {
free(tex->data);
}
free(tex);
tex = NULL;
}
}