449 int cxMapRehash(CxMap *map) { |
450 int cxMapRehash(CxMap *map) { |
450 struct cx_hash_map_s *hash_map = (struct cx_hash_map_s *) map; |
451 struct cx_hash_map_s *hash_map = (struct cx_hash_map_s *) map; |
451 if (map->collection.size > ((hash_map->bucket_count * 3) >> 2)) { |
452 if (map->collection.size > ((hash_map->bucket_count * 3) >> 2)) { |
452 |
453 |
453 size_t new_bucket_count = (map->collection.size * 5) >> 1; |
454 size_t new_bucket_count = (map->collection.size * 5) >> 1; |
|
455 if (new_bucket_count < hash_map->bucket_count) { |
|
456 errno = EOVERFLOW; |
|
457 return 1; |
|
458 } |
454 struct cx_hash_map_element_s **new_buckets = cxCalloc( |
459 struct cx_hash_map_element_s **new_buckets = cxCalloc( |
455 map->collection.allocator, |
460 map->collection.allocator, |
456 new_bucket_count, sizeof(struct cx_hash_map_element_s *) |
461 new_bucket_count, sizeof(struct cx_hash_map_element_s *) |
457 ); |
462 ); |
458 |
463 |