only retain cached attributes once

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37319 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2013-10-29 16:05:29 +00:00
parent 5ecbbfe3bb
commit 4ebaa799a5

View file

@ -151,7 +151,7 @@ cacheAttributes(NSDictionary *attrs)
else else
{ {
node->value.nsu++; node->value.nsu++;
attrs = RETAIN(node->key.obj); attrs = node->key.obj;
} }
AUNLOCK(); AUNLOCK();
} }
@ -167,9 +167,8 @@ unCacheAttributes(NSDictionary *attrs)
if (nil != attrs) if (nil != attrs)
{ {
GSIMapBucket bucket; GSIMapBucket bucket;
NSDictionary *found; NSDictionary *removed = nil;
found = nil;
ALOCK(); ALOCK();
bucket = GSIMapBucketForKey(&attrMap, (GSIMapKey)((id)attrs)); bucket = GSIMapBucketForKey(&attrMap, (GSIMapKey)((id)attrs));
if (bucket != 0) if (bucket != 0)
@ -180,17 +179,16 @@ unCacheAttributes(NSDictionary *attrs)
bucket, (GSIMapKey)((id)attrs)); bucket, (GSIMapKey)((id)attrs));
if (node != 0) if (node != 0)
{ {
found = node->key.obj;
if (--node->value.nsu == 0) if (--node->value.nsu == 0)
{ {
removed = node->key.obj;
GSIMapRemoveNodeFromMap(&attrMap, bucket, node); GSIMapRemoveNodeFromMap(&attrMap, bucket, node);
GSIMapFreeNode(&attrMap, node); GSIMapFreeNode(&attrMap, node);
} }
} }
} }
AUNLOCK(); AUNLOCK();
NSCAssert(found == attrs, NSInternalInconsistencyException); RELEASE(removed);
RELEASE(found);
} }
} }