From 7c914cdca4e24a2a16a0fce9886bfe803e00be25 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Thu, 27 Feb 2020 00:47:09 +0800 Subject: [PATCH] fix a bug: uninitialize the callback functions for the map of system bitmaps; add __mg_map_get_size --- src/include/map.h | 1 + src/misc/map.c | 11 +++++++++++ src/sysres/resmgr.c | 1 - src/sysres/resource.c | 4 +++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/include/map.h b/src/include/map.h index 962f0c9d..8122a1aa 100644 --- a/src/include/map.h +++ b/src/include/map.h @@ -85,6 +85,7 @@ map_entry_t* __mg_map_find (map_t* map, const void* key); int __mg_map_insert (map_t* map, const void* key, const void* val); void* __mg_map_find_or_insert (map_t* map, const void* key, const void* val); int __mg_map_erase (map_t* map, void* key); +int __mg_map_get_size (map_t* map); #ifdef __cplusplus } diff --git a/src/misc/map.c b/src/misc/map.c index 65caee1d..13965356 100644 --- a/src/misc/map.c +++ b/src/misc/map.c @@ -101,10 +101,21 @@ map_t* __mg_map_create (copy_key_fn copy_key, free_key_fn free_key, if (!(map = calloc (1, sizeof(map_t)))) return NULL; + map->copy_key = copy_key; + map->free_key = free_key; + map->copy_val = copy_val; + map->free_val = free_val; + map->comp_key = comp_key; + WRLOCK_INIT (map); return map; } +int __mg_map_get_size (map_t* map) +{ + return map->size; +} + int __mg_map_destroy (map_t* map) { if (map == NULL) diff --git a/src/sysres/resmgr.c b/src/sysres/resmgr.c index c9d317b0..b7da5219 100644 --- a/src/sysres/resmgr.c +++ b/src/sysres/resmgr.c @@ -487,7 +487,6 @@ void TerminateResManager() /* Since 5.0.0, destroy the map for system bitmaps */ __mg_map_destroy (__mg_sys_bmp_map); - } const char* __sysres_get_system_res_path() diff --git a/src/sysres/resource.c b/src/sysres/resource.c index d4bee752..030a841b 100644 --- a/src/sysres/resource.c +++ b/src/sysres/resource.c @@ -386,6 +386,8 @@ BOOL GUIAPI RegisterSystemBitmap (HDC hdc, const char* rdr_name, const char* id) free (bmp); return FALSE; } + + _DBG_PRINTF ("Registered system bitmap for key: %s\n", key); } return TRUE; @@ -416,7 +418,7 @@ void GUIAPI UnregisterSystemBitmap (HDC hdc, const char* rdr_name, const char* i } if (__mg_map_erase (__mg_sys_bmp_map, key)) { - _WRN_PRINTF ("not registered system bitmap: %s.%s\n", rdr_name, id); + _WRN_PRINTF ("not registered system bitmap for key: %s\n", key); return; }