summaryrefslogtreecommitdiffstats
path: root/core/hash_map.h
diff options
context:
space:
mode:
authorqarmin <mikrutrafal54@gmail.com>2019-06-03 21:52:50 +0200
committerqarmin <mikrutrafal54@gmail.com>2019-06-03 21:52:50 +0200
commit8245db869f05a86e88338236d22765b87cc71db8 (patch)
tree9cad264ada4820d48d6952f1a5564b32cb1619f2 /core/hash_map.h
parent8c923fc61740afd560e6c814f7ef19b0cdc30112 (diff)
downloadredot-engine-8245db869f05a86e88338236d22765b87cc71db8.tar.gz
Small fixes to unrechable code, possibly overflows, using NULL pointers
Diffstat (limited to 'core/hash_map.h')
-rw-r--r--core/hash_map.h19
1 files changed, 10 insertions, 9 deletions
diff --git a/core/hash_map.h b/core/hash_map.h
index 44459a3080..31332991de 100644
--- a/core/hash_map.h
+++ b/core/hash_map.h
@@ -162,20 +162,21 @@ private:
new_hash_table[i] = 0;
}
- for (int i = 0; i < (1 << hash_table_power); i++) {
+ if (hash_table) {
+ for (int i = 0; i < (1 << hash_table_power); i++) {
- while (hash_table[i]) {
+ while (hash_table[i]) {
- Element *se = hash_table[i];
- hash_table[i] = se->next;
- int new_pos = se->hash & ((1 << new_hash_table_power) - 1);
- se->next = new_hash_table[new_pos];
- new_hash_table[new_pos] = se;
+ Element *se = hash_table[i];
+ hash_table[i] = se->next;
+ int new_pos = se->hash & ((1 << new_hash_table_power) - 1);
+ se->next = new_hash_table[new_pos];
+ new_hash_table[new_pos] = se;
+ }
}
- }
- if (hash_table)
memdelete_arr(hash_table);
+ }
hash_table = new_hash_table;
hash_table_power = new_hash_table_power;
}