# HG changeset patch # User ib # Date 1299089660 0 # Node ID 9949f3a123cf52b9210736b5d6a5437ec6c89fcc # Parent 5fdd52feb5ea585c778f2f8da27bd98125b3efda Add new function bpFree() to free txSamples (bitmaps). (Note: None of the systems known or tested have a problem with initializing numeric zero and pointer null as all-bits-zero.) diff -r 5fdd52feb5ea -r 9949f3a123cf gui/app.c --- a/gui/app.c Wed Mar 02 17:42:06 2011 +0000 +++ b/gui/app.c Wed Mar 02 18:14:20 2011 +0000 @@ -88,12 +88,7 @@ item->message = 0; item->pressed = btnReleased; item->tmp = 0; - item->Bitmap.Width = 0; - item->Bitmap.Height = 0; - item->Bitmap.BPP = 0; - item->Bitmap.ImageSize = 0; - free(item->Bitmap.Image); - item->Bitmap.Image = NULL; + bpFree(&item->Bitmap); item->fontid = 0; free(item->label); item->label = NULL; diff -r 5fdd52feb5ea -r 9949f3a123cf gui/bitmap.c --- a/gui/bitmap.c Wed Mar 02 17:42:06 2011 +0000 +++ b/gui/bitmap.c Wed Mar 02 18:14:20 2011 +0000 @@ -206,6 +206,12 @@ return 0; } +void bpFree(txSample *bf) +{ + free(bf->Image); + memset(bf, 0, sizeof(*bf)); +} + void Convert32to1(txSample *in, txSample *out, int adaptivlimit) { out->Width = in->Width; diff -r 5fdd52feb5ea -r 9949f3a123cf gui/bitmap.h --- a/gui/bitmap.h Wed Mar 02 17:42:06 2011 +0000 +++ b/gui/bitmap.h Wed Mar 02 18:14:20 2011 +0000 @@ -27,6 +27,7 @@ char *Image; } txSample; +void bpFree(txSample *); int bpRead(char *, txSample *); void Convert32to1(txSample *, txSample *, int); diff -r 5fdd52feb5ea -r 9949f3a123cf gui/skin/font.c --- a/gui/skin/font.c Wed Mar 02 17:42:06 2011 +0000 +++ b/gui/skin/font.c Wed Mar 02 18:14:20 2011 +0000 @@ -65,7 +65,7 @@ for (i = 0; i < MAX_FONTS; i++) { if (Fonts[i]) { - gfree((void **)&Fonts[i]->Bitmap.Image); + bpFree(&Fonts[i]->Bitmap); gfree((void **)&Fonts[i]); } } @@ -154,7 +154,7 @@ mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[font] image file: %s\n", tmp); if (skinBPRead(tmp, &Fonts[id]->Bitmap) != 0) { - gfree((void **)&Fonts[id]->Bitmap.Image); + bpFree(&Fonts[id]->Bitmap); gfree((void **)&Fonts[id]); fclose(f); return -4; @@ -287,7 +287,7 @@ th = fntTextHeight(id, txt); if (item->height != th) - gfree((void **)&item->Bitmap.Image); + bpFree(&item->Bitmap); if (!item->Bitmap.Image) { item->Bitmap.Height = item->height = th;