comparison gui/app.c @ 32921:448517f556a5

Fix memory leak in appClearItem(). Mask wasn't freed. Additionally: symbolic constants are used for initialization where possible, the pressed default is btnDisabled now, gfree() is preferred to free() and setting NULL, and statements are rearranged according to members in structure.
author ib
date Thu, 03 Mar 2011 11:43:01 +0000
parents efb929029ec9
children 4546e629ae70
comparison
equal deleted inserted replaced
32920:8661ae44ef39 32921:448517f556a5
18 18
19 #include <stdlib.h> 19 #include <stdlib.h>
20 #include <string.h> 20 #include <string.h>
21 21
22 #include "app.h" 22 #include "app.h"
23
24 #include "gui/skin/font.h"
25 #include "interface.h"
23 26
24 listItems appMPlayer; 27 listItems appMPlayer;
25 28
26 static const evName evNames[] = { 29 static const evName evNames[] = {
27 { evNone, "evNone" }, 30 { evNone, "evNone" },
76 79
77 static const int evBoxs = sizeof(evNames) / sizeof(evName); 80 static const int evBoxs = sizeof(evNames) / sizeof(evName);
78 81
79 static void appClearItem(wItem *item) 82 static void appClearItem(wItem *item)
80 { 83 {
81 item->type = 0; 84 item->type = itNone;
82 item->x = 0; 85 item->x = 0;
83 item->y = 0; 86 item->y = 0;
84 item->width = 0; 87 item->width = 0;
85 item->height = 0; 88 item->height = 0;
86 item->pwidth = 0;
87 item->pheight = 0;
88 item->message = 0;
89 item->pressed = btnReleased;
90 item->tmp = 0;
91 bpFree(&item->Bitmap); 89 bpFree(&item->Bitmap);
90 bpFree(&item->Mask);
92 item->fontid = 0; 91 item->fontid = 0;
93 free(item->label); 92 item->align = fntAlignLeft;
94 item->label = NULL; 93 gfree((void **)&item->label);
95 free(item->text); 94 item->pwidth = 0;
96 item->text = NULL; 95 item->pheight = 0;
96 item->numphases = 0;
97 item->value = 0;
98 item->message = evNone;
99 item->R = 0;
100 item->G = 0;
101 item->B = 0;
102 gfree((void **)&item->text);
97 item->textwidth = 0; 103 item->textwidth = 0;
98 item->starttime = 0; 104 item->starttime = 0;
99 item->last_x = 0; 105 item->last_x = 0;
106 item->pressed = btnDisabled;
107 item->tmp = 0;
100 } 108 }
101 109
102 void appInitStruct(listItems *item) 110 void appInitStruct(listItems *item)
103 { 111 {
104 int i; 112 int i;