fix nil checks on hash table functions
This commit is contained in:
parent
a7d571bd5a
commit
8cb9e30a1d
6
util.d
6
util.d
@ -406,7 +406,7 @@ Push(K, V)(HashTable!(K, V)* ht, K key, V value)
|
|||||||
|
|
||||||
N* node = ht.nil;
|
N* node = ht.nil;
|
||||||
|
|
||||||
if (ht.free_lists.first != ht.nil)
|
if (CheckNil(ht.nil, ht.free_lists.first))
|
||||||
{
|
{
|
||||||
node = SLLPop(&ht.free_lists, ht.nil);
|
node = SLLPop(&ht.free_lists, ht.nil);
|
||||||
}
|
}
|
||||||
@ -432,7 +432,7 @@ Search(K, V)(HashTable!(K, V)* ht, K key)
|
|||||||
KVPair!(K, V)* result = null;
|
KVPair!(K, V)* result = null;
|
||||||
|
|
||||||
auto list = GetList(ht, key);
|
auto list = GetList(ht, key);
|
||||||
for(auto node = list.first; node != ht.nil; node = node.next)
|
for(auto node = list.first; CheckNil(ht.nil, node); node = node.next)
|
||||||
{
|
{
|
||||||
if (node.value.key == key)
|
if (node.value.key == key)
|
||||||
{
|
{
|
||||||
@ -459,7 +459,7 @@ Delete(K, V)(HashTable!(K, V)* ht, K key)
|
|||||||
|
|
||||||
auto list = GetList(ht, key);
|
auto list = GetList(ht, key);
|
||||||
auto prev = ht.nil;
|
auto prev = ht.nil;
|
||||||
for(auto node = list.first; node != ht.nil; node = node.next)
|
for(auto node = list.first; CheckNil(ht.nil, node); node = node.next)
|
||||||
{
|
{
|
||||||
if (node.value.key == key)
|
if (node.value.key == key)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user