mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-02 09:31:07 +00:00
check for nil
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37318 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
07152c53ae
commit
5ecbbfe3bb
1 changed files with 46 additions and 38 deletions
|
@ -132,18 +132,21 @@ static IMP unlockImp;
|
||||||
static NSDictionary*
|
static NSDictionary*
|
||||||
cacheAttributes(NSDictionary *attrs)
|
cacheAttributes(NSDictionary *attrs)
|
||||||
{
|
{
|
||||||
|
if (nil != attrs)
|
||||||
|
{
|
||||||
GSIMapNode node;
|
GSIMapNode node;
|
||||||
|
|
||||||
ALOCK();
|
ALOCK();
|
||||||
node = GSIMapNodeForKey(&attrMap, (GSIMapKey)((id)attrs));
|
node = GSIMapNodeForKey(&attrMap, (GSIMapKey)((id)attrs));
|
||||||
if (node == 0)
|
if (node == 0)
|
||||||
{
|
{
|
||||||
/*
|
/* Shallow copy of dictionary, without copying objects ....
|
||||||
* Shallow copy of dictionary, without copying objects ... results
|
* result in an immutable dictionary that can safely be cached.
|
||||||
* in an immutable dictionary that can safely be cached.
|
|
||||||
*/
|
*/
|
||||||
attrs = [[NSDictionary alloc] initWithDictionary: attrs copyItems: NO];
|
attrs = [[NSDictionary alloc] initWithDictionary: attrs
|
||||||
GSIMapAddPair(&attrMap, (GSIMapKey)((id)attrs), (GSIMapVal)(NSUInteger)1);
|
copyItems: NO];
|
||||||
|
GSIMapAddPair(&attrMap,
|
||||||
|
(GSIMapKey)((id)attrs), (GSIMapVal)(NSUInteger)1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -151,6 +154,7 @@ cacheAttributes(NSDictionary *attrs)
|
||||||
attrs = RETAIN(node->key.obj);
|
attrs = RETAIN(node->key.obj);
|
||||||
}
|
}
|
||||||
AUNLOCK();
|
AUNLOCK();
|
||||||
|
}
|
||||||
return attrs;
|
return attrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,6 +164,8 @@ cacheAttributes(NSDictionary *attrs)
|
||||||
static void
|
static void
|
||||||
unCacheAttributes(NSDictionary *attrs)
|
unCacheAttributes(NSDictionary *attrs)
|
||||||
{
|
{
|
||||||
|
if (nil != attrs)
|
||||||
|
{
|
||||||
GSIMapBucket bucket;
|
GSIMapBucket bucket;
|
||||||
NSDictionary *found;
|
NSDictionary *found;
|
||||||
|
|
||||||
|
@ -170,7 +176,8 @@ unCacheAttributes(NSDictionary *attrs)
|
||||||
{
|
{
|
||||||
GSIMapNode node;
|
GSIMapNode node;
|
||||||
|
|
||||||
node = GSIMapNodeForKeyInBucket(&attrMap, bucket, (GSIMapKey)((id)attrs));
|
node = GSIMapNodeForKeyInBucket(&attrMap,
|
||||||
|
bucket, (GSIMapKey)((id)attrs));
|
||||||
if (node != 0)
|
if (node != 0)
|
||||||
{
|
{
|
||||||
found = node->key.obj;
|
found = node->key.obj;
|
||||||
|
@ -184,6 +191,7 @@ unCacheAttributes(NSDictionary *attrs)
|
||||||
AUNLOCK();
|
AUNLOCK();
|
||||||
NSCAssert(found == attrs, NSInternalInconsistencyException);
|
NSCAssert(found == attrs, NSInternalInconsistencyException);
|
||||||
RELEASE(found);
|
RELEASE(found);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue