mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 15:02:20 +00:00
[BUG] Corrected some bugs introduced in r383
[BUG] GRRLIB_FreeBMF was not freeing the memory completely
This commit is contained in:
parent
09c55dd214
commit
1561726543
3 changed files with 11 additions and 5 deletions
|
@ -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; i<bmf->nbChar; 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -86,11 +86,12 @@ void GRRLIB_PrintBMF (const f32 xpos, const f32 ypos,
|
|||
pdata = pchar->data;
|
||||
for (y=0; y<pchar->height; y++) {
|
||||
for (x=0; x<pchar->width; x++) {
|
||||
if (*pdata++) {
|
||||
if (*pdata) {
|
||||
GRRLIB_Plot(xoff + x + pchar->relx,
|
||||
ypos + y + pchar->rely,
|
||||
bmf->palette[*pdata]);
|
||||
}
|
||||
pdata++;
|
||||
}
|
||||
}
|
||||
xoff += pchar->kerning + bmf->tracking;
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue