mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Merge pull request #91 from gnustep/weak_hash_map
* Headers/GNUstepBase/GSIMap.h: Use GSI_MAP_NODE_IS_EMPTY macros
This commit is contained in:
commit
35bb623eac
4 changed files with 29 additions and 18 deletions
|
@ -1,3 +1,10 @@
|
|||
2019-12-15 Fred Kiefer <fredkiefer@gmx.de>
|
||||
|
||||
* Headers/GNUstepBase/GSIMap.h: Use GSI_MAP_NODE_IS_EMPTY macros
|
||||
when checking in enumerator.
|
||||
* Source/NSConcreteHashTable.m,
|
||||
* Source/NSConcreteMapTable.m: Revert part of the weak pointer change.
|
||||
|
||||
2019-10-17 Frederik Seiffert <frederik@algoriddim.com>
|
||||
|
||||
* Tests/base/NSHashTable/weakObjects.m:
|
||||
|
|
|
@ -945,7 +945,7 @@ GSIMapEnumeratorNextNode(GSIMapEnumerator enumerator)
|
|||
{
|
||||
uintptr_t bucket = ((_GSIE)enumerator)->bucket;
|
||||
|
||||
while (next != 0 && next->key.addr == 0)
|
||||
while (next != 0 && GSI_MAP_NODE_IS_EMPTY(map, next))
|
||||
{
|
||||
next = GSIMapRemoveAndFreeNode(map, bucket, next);
|
||||
}
|
||||
|
@ -961,7 +961,7 @@ GSIMapEnumeratorNextNode(GSIMapEnumerator enumerator)
|
|||
while (next == 0 && ++bucket < bucketCount)
|
||||
{
|
||||
next = (map->buckets[bucket]).firstNode;
|
||||
while (next != 0 && next->key.addr == 0)
|
||||
while (next != 0 && GSI_MAP_NODE_IS_EMPTY(map, next))
|
||||
{
|
||||
next = GSIMapRemoveAndFreeNode(map, bucket, next);
|
||||
}
|
||||
|
|
|
@ -627,13 +627,9 @@ NSNextHashEnumeratorItem(NSHashEnumerator *enumerator)
|
|||
}
|
||||
else
|
||||
{
|
||||
NSConcreteHashTable *map = enumerator->map;
|
||||
GSIMapKey k = GSI_MAP_READ_KEY(map, &n->key);
|
||||
if (k.ptr == NULL)
|
||||
{
|
||||
return NSNextHashEnumeratorItem(enumerator);
|
||||
}
|
||||
return k.ptr;
|
||||
NSConcreteHashTable *map = enumerator->map;
|
||||
|
||||
return GSI_MAP_READ_KEY(map, &n->key).ptr;
|
||||
}
|
||||
}
|
||||
else if (enumerator->node != 0) // Got an enumerator object
|
||||
|
|
|
@ -882,17 +882,25 @@ NSNextMapEnumeratorPair(NSMapEnumerator *enumerator,
|
|||
}
|
||||
else
|
||||
{
|
||||
NSConcreteMapTable *map = enumerator->map;
|
||||
GSIMapKey k = GSI_MAP_READ_KEY(map, &n->key);
|
||||
GSIMapVal v = GSI_MAP_READ_VALUE(map, &n->value);
|
||||
if (k.ptr == NULL || v.ptr == NULL)
|
||||
{
|
||||
return NSNextMapEnumeratorPair(enumerator, key, value);
|
||||
NSConcreteMapTable *map = enumerator->map;
|
||||
|
||||
if (key != 0)
|
||||
{
|
||||
*key = GSI_MAP_READ_KEY(map, &n->key).ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSWarnFLog(@"Null key return address");
|
||||
}
|
||||
|
||||
*key = k.ptr;
|
||||
*value = v.ptr;
|
||||
|
||||
if (value != 0)
|
||||
{
|
||||
*value = GSI_MAP_READ_VALUE(map, &n->value).ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSWarnFLog(@"Null value return address");
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue