[MPlayer-cvslog] r33004 - in trunk/gui: app.c bitmap.c bitmap.h skin/font.c

ib subversion at mplayerhq.hu
Wed Mar 2 19:14:20 CET 2011


Author: ib
Date: Wed Mar  2 19:14:20 2011
New Revision: 33004

Log:
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.)

Modified:
   trunk/gui/app.c
   trunk/gui/bitmap.c
   trunk/gui/bitmap.h
   trunk/gui/skin/font.c

Modified: trunk/gui/app.c
==============================================================================
--- trunk/gui/app.c	Wed Mar  2 18:42:06 2011	(r33003)
+++ trunk/gui/app.c	Wed Mar  2 19:14:20 2011	(r33004)
@@ -88,12 +88,7 @@ static void appClearItem(wItem *item)
     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;

Modified: trunk/gui/bitmap.c
==============================================================================
--- trunk/gui/bitmap.c	Wed Mar  2 18:42:06 2011	(r33003)
+++ trunk/gui/bitmap.c	Wed Mar  2 19:14:20 2011	(r33004)
@@ -206,6 +206,12 @@ int bpRead(char *fname, txSample *bf)
     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;

Modified: trunk/gui/bitmap.h
==============================================================================
--- trunk/gui/bitmap.h	Wed Mar  2 18:42:06 2011	(r33003)
+++ trunk/gui/bitmap.h	Wed Mar  2 19:14:20 2011	(r33004)
@@ -27,6 +27,7 @@ typedef struct {
     char *Image;
 } txSample;
 
+void bpFree(txSample *);
 int bpRead(char *, txSample *);
 void Convert32to1(txSample *, txSample *, int);
 

Modified: trunk/gui/skin/font.c
==============================================================================
--- trunk/gui/skin/font.c	Wed Mar  2 18:42:06 2011	(r33003)
+++ trunk/gui/skin/font.c	Wed Mar  2 19:14:20 2011	(r33004)
@@ -65,7 +65,7 @@ void fntFreeFont(void)
 
     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 @@ int fntRead(char *path, char *fname)
             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 @@ txSample *fntRender(wItem *item, int px,
     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;


More information about the MPlayer-cvslog mailing list