mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Encourage better coding by warning about attempts to remove nil objects
from arrays. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@5131 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b9fe4e75e2
commit
11d14c597d
6 changed files with 88 additions and 32 deletions
|
@ -254,23 +254,25 @@
|
|||
|
||||
- (void) removeObject: (NSObject*)anObject
|
||||
{
|
||||
if (anObject)
|
||||
GSIMapBucket bucket;
|
||||
|
||||
if (anObject == nil)
|
||||
{
|
||||
GSIMapBucket bucket;
|
||||
NSLog(@"attempt to remove nil object");
|
||||
return;
|
||||
}
|
||||
bucket = GSIMapBucketForKey(&map, (GSIMapKey)anObject);
|
||||
if (bucket != 0)
|
||||
{
|
||||
GSIMapNode node;
|
||||
|
||||
bucket = GSIMapBucketForKey(&map, (GSIMapKey)anObject);
|
||||
if (bucket)
|
||||
node = GSIMapNodeForKeyInBucket(bucket, (GSIMapKey)anObject);
|
||||
if (node != 0)
|
||||
{
|
||||
GSIMapNode node;
|
||||
|
||||
node = GSIMapNodeForKeyInBucket(bucket, (GSIMapKey)anObject);
|
||||
if (node)
|
||||
if (--node->value.uint == 0)
|
||||
{
|
||||
if (--node->value.uint == 0)
|
||||
{
|
||||
GSIMapRemoveNodeFromMap(&map, bucket, node);
|
||||
GSIMapFreeNode(&map, node);
|
||||
}
|
||||
GSIMapRemoveNodeFromMap(&map, bucket, node);
|
||||
GSIMapFreeNode(&map, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue