Apply clang-format for core/shared and product-mini files (#785)
Apply clang-format for core/shared and product-mini files
This commit is contained in:
@ -25,11 +25,9 @@ struct HashMap {
|
||||
HashMapElem *elements[1];
|
||||
};
|
||||
|
||||
HashMap*
|
||||
bh_hash_map_create(uint32 size, bool use_lock,
|
||||
HashFunc hash_func,
|
||||
KeyEqualFunc key_equal_func,
|
||||
KeyDestroyFunc key_destroy_func,
|
||||
HashMap *
|
||||
bh_hash_map_create(uint32 size, bool use_lock, HashFunc hash_func,
|
||||
KeyEqualFunc key_equal_func, KeyDestroyFunc key_destroy_func,
|
||||
ValueDestroyFunc value_destroy_func)
|
||||
{
|
||||
HashMap *map;
|
||||
@ -42,16 +40,15 @@ bh_hash_map_create(uint32 size, bool use_lock,
|
||||
|
||||
if (!hash_func || !key_equal_func) {
|
||||
LOG_ERROR("HashMap create failed: hash function or key equal function "
|
||||
" is NULL.\n");
|
||||
" is NULL.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
total_size = offsetof(HashMap, elements) +
|
||||
sizeof(HashMapElem *) * (uint64)size +
|
||||
(use_lock ? sizeof(korp_mutex) : 0);
|
||||
total_size = offsetof(HashMap, elements)
|
||||
+ sizeof(HashMapElem *) * (uint64)size
|
||||
+ (use_lock ? sizeof(korp_mutex) : 0);
|
||||
|
||||
if (total_size >= UINT32_MAX
|
||||
|| !(map = BH_MALLOC((uint32)total_size))) {
|
||||
if (total_size >= UINT32_MAX || !(map = BH_MALLOC((uint32)total_size))) {
|
||||
LOG_ERROR("HashMap create failed: alloc memory failed.\n");
|
||||
return NULL;
|
||||
}
|
||||
@ -59,9 +56,8 @@ bh_hash_map_create(uint32 size, bool use_lock,
|
||||
memset(map, 0, (uint32)total_size);
|
||||
|
||||
if (use_lock) {
|
||||
map->lock = (korp_mutex*)
|
||||
((uint8*)map + offsetof(HashMap, elements)
|
||||
+ sizeof(HashMapElem *) * size);
|
||||
map->lock = (korp_mutex *)((uint8 *)map + offsetof(HashMap, elements)
|
||||
+ sizeof(HashMapElem *) * size);
|
||||
if (os_mutex_init(map->lock)) {
|
||||
LOG_ERROR("HashMap create failed: init map lock failed.\n");
|
||||
BH_FREE(map);
|
||||
@ -124,7 +120,7 @@ fail:
|
||||
return false;
|
||||
}
|
||||
|
||||
void*
|
||||
void *
|
||||
bh_hash_map_find(HashMap *map, void *key)
|
||||
{
|
||||
uint32 index;
|
||||
@ -161,8 +157,7 @@ bh_hash_map_find(HashMap *map, void *key)
|
||||
}
|
||||
|
||||
bool
|
||||
bh_hash_map_update(HashMap *map, void *key, void *value,
|
||||
void **p_old_value)
|
||||
bh_hash_map_update(HashMap *map, void *key, void *value, void **p_old_value)
|
||||
{
|
||||
uint32 index;
|
||||
HashMapElem *elem;
|
||||
@ -199,8 +194,8 @@ bh_hash_map_update(HashMap *map, void *key, void *value,
|
||||
}
|
||||
|
||||
bool
|
||||
bh_hash_map_remove(HashMap *map, void *key,
|
||||
void **p_old_key, void **p_old_value)
|
||||
bh_hash_map_remove(HashMap *map, void *key, void **p_old_key,
|
||||
void **p_old_value)
|
||||
{
|
||||
uint32 index;
|
||||
HashMapElem *elem, *prev;
|
||||
|
||||
Reference in New Issue
Block a user