diff --git a/GRRLIB/GRRLIB/GRRLIB_bmf.c b/GRRLIB/GRRLIB/GRRLIB_bmf.c index 4f85edf..2a2c296 100644 --- a/GRRLIB/GRRLIB/GRRLIB_bmf.c +++ b/GRRLIB/GRRLIB/GRRLIB_bmf.c @@ -59,6 +59,7 @@ GRRLIB_bytemapFont* GRRLIB_LoadBMF (const u8 my_bmf[] ) { memcpy(fontArray->name, &my_bmf[18 + numcolpal], j); j = 18 + numcolpal + j; fontArray->nbChar = (my_bmf[j] | my_bmf[j+1]<<8); + memset(fontArray->charDef, 0, 256 * sizeof(GRRLIB_bytemapChar)); j++; for (i=0; i < fontArray->nbChar; i++) { c = my_bmf[++j]; @@ -82,14 +83,18 @@ GRRLIB_bytemapFont* GRRLIB_LoadBMF (const u8 my_bmf[] ) { * Free memory allocated by ByteMap fonts. * @param bmf A GRRLIB_bytemapFont structure. */ -void GRRLIB_FreeBMF (const GRRLIB_bytemapFont *bmf) { +void GRRLIB_FreeBMF (GRRLIB_bytemapFont *bmf) { u16 i; - for (i=0; inbChar; i++) { - free(bmf->charDef[i].data); + for (i=0; i<256; i++) { + if(bmf->charDef[i].data) { + free(bmf->charDef[i].data); + } } free(bmf->palette); free(bmf->name); + free(bmf); + bmf = NULL; } /** diff --git a/GRRLIB/GRRLIB/GRRLIB_print.c b/GRRLIB/GRRLIB/GRRLIB_print.c index b152a7c..7ecffe0 100644 --- a/GRRLIB/GRRLIB/GRRLIB_print.c +++ b/GRRLIB/GRRLIB/GRRLIB_print.c @@ -86,11 +86,12 @@ void GRRLIB_PrintBMF (const f32 xpos, const f32 ypos, pdata = pchar->data; for (y=0; yheight; y++) { for (x=0; xwidth; x++) { - if (*pdata++) { + if (*pdata) { GRRLIB_Plot(xoff + x + pchar->relx, ypos + y + pchar->rely, bmf->palette[*pdata]); } + pdata++; } } xoff += pchar->kerning + bmf->tracking; diff --git a/GRRLIB/GRRLIB/grrlib/GRRLIB__lib.h b/GRRLIB/GRRLIB/grrlib/GRRLIB__lib.h index e8adc39..ee27473 100644 --- a/GRRLIB/GRRLIB/grrlib/GRRLIB__lib.h +++ b/GRRLIB/GRRLIB/grrlib/GRRLIB__lib.h @@ -44,7 +44,7 @@ THE SOFTWARE. //------------------------------------------------------------------------------ // GRRLIB_bmf.c - BitMapFont functions GRRLIB_bytemapFont* GRRLIB_LoadBMF (const u8 my_bmf[] ); -void GRRLIB_FreeBMF (const GRRLIB_bytemapFont *bmf); +void GRRLIB_FreeBMF (GRRLIB_bytemapFont *bmf); void GRRLIB_InitTileSet (GRRLIB_texImg *tex, const uint tilew, const uint tileh,