mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2025-12-15 00:45:35 +08:00
enhance code for some uninitialized fields
This commit is contained in:
@@ -149,7 +149,7 @@ typedef struct _ZORDERINFO {
|
||||
#ifdef _MGRM_THREADS
|
||||
# ifdef __ZI_USE_RWLOCK
|
||||
pthread_rwlock_t rwlock;
|
||||
pthread_t wrlock_owner;
|
||||
pthread_t rwlock_owner;
|
||||
# else
|
||||
pthread_mutex_t mutex;
|
||||
# endif
|
||||
|
||||
@@ -601,18 +601,18 @@ static void reset_window (PMAINWIN pWin, RECT* rcWin)
|
||||
static inline void lock_zi_for_change (ZORDERINFO* zi)
|
||||
{
|
||||
pthread_rwlock_wrlock(&zi->rwlock);
|
||||
zi->wrlock_owner = pthread_self();
|
||||
zi->rwlock_owner = pthread_self();
|
||||
}
|
||||
|
||||
static inline void unlock_zi_for_change (ZORDERINFO* zi)
|
||||
{
|
||||
pthread_rwlock_unlock(&zi->rwlock);
|
||||
zi->wrlock_owner = 0;
|
||||
zi->rwlock_owner = 0;
|
||||
}
|
||||
|
||||
static inline void lock_zi_for_read (ZORDERINFO* zi)
|
||||
{
|
||||
if (zi->wrlock_owner == pthread_self()) {
|
||||
if (zi->rwlock_owner == pthread_self()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -621,7 +621,7 @@ static inline void lock_zi_for_read (ZORDERINFO* zi)
|
||||
|
||||
static inline void unlock_zi_for_read (ZORDERINFO* zi)
|
||||
{
|
||||
if (zi->wrlock_owner == pthread_self()) {
|
||||
if (zi->rwlock_owner == pthread_self()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -245,6 +245,7 @@ int __kernel_alloc_z_order_info (int nr_topmosts, int nr_normals, BOOL with_mask
|
||||
#ifdef _MGRM_THREADS
|
||||
# ifdef __ZI_USE_RWLOCK
|
||||
pthread_rwlock_init(&__mg_zorder_info->rwlock, NULL);
|
||||
__mg_zorder_info->rwlock_owner = 0;
|
||||
# else
|
||||
do {
|
||||
int ret;
|
||||
|
||||
@@ -187,7 +187,8 @@ int __mg_bmp_compute_pitch(int bpp, Uint32 width, Uint32 *pitch, BOOL does_round
|
||||
return bytespp;
|
||||
}
|
||||
|
||||
void* GUIAPI InitMyBitmapSL (MG_RWops* area, const char* ext, MYBITMAP* my_bmp, RGB* pal)
|
||||
void* GUIAPI
|
||||
InitMyBitmapSL (MG_RWops* area, const char* ext, MYBITMAP* my_bmp, RGB* pal)
|
||||
{
|
||||
int type;
|
||||
LOAD_MYBITMAP_INFO* load_info;
|
||||
@@ -209,8 +210,11 @@ void* GUIAPI InitMyBitmapSL (MG_RWops* area, const char* ext, MYBITMAP* my_bmp,
|
||||
my_bmp->frames = 1;
|
||||
my_bmp->depth = GetGDCapability (HDC_SCREEN, GDCAP_BPP) << 3;
|
||||
|
||||
// initialize the palette with the screen palette.
|
||||
if (my_bmp->depth <= 8)
|
||||
GetPalette (HDC_SCREEN, 0, 256, (GAL_Color*)pal);
|
||||
else
|
||||
memset (pal, 0, sizeof(RGB) * 256); // reset the palette.
|
||||
|
||||
/* This is just for gray screen. If your screen is gray,
|
||||
* please define this macro _GRAY_SCREEN.
|
||||
|
||||
@@ -148,14 +148,15 @@ static BOOL find_color_key (GAL_PixelFormat* format, const MYBITMAP* my_bmp,
|
||||
goto free_and_ret;
|
||||
|
||||
color_num = 1 << my_bmp->depth;
|
||||
pixels = malloc (color_num * sizeof (Uint32));
|
||||
for (i = 0; i < color_num; i++)
|
||||
pixels = calloc (color_num, sizeof (Uint32));
|
||||
for (i = 0; i < color_num; i++) {
|
||||
pixels[i] = GAL_MapRGB (format, pal[i].r, pal[i].g, pal[i].b);
|
||||
}
|
||||
pixel_key = pixels [my_bmp->transparent];
|
||||
|
||||
for (i = 0; i < color_num; i++) {
|
||||
if (pixels[i] == pixel_key && i != my_bmp->transparent)
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == color_num)
|
||||
|
||||
@@ -1001,7 +1001,7 @@ static inline MYBMP_WITH_PAL* new_mybmp_with_pal (void)
|
||||
MYBMP_WITH_PAL* mybmp_pal;
|
||||
|
||||
mybmp_pal = NEW(MYBMP_WITH_PAL);
|
||||
mybmp_pal->pal = malloc (sizeof (RGB) * 256);
|
||||
mybmp_pal->pal = calloc (256, sizeof (RGB));
|
||||
return mybmp_pal;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user