mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Fix bug handling nil/NSNull and a memory leak.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@18550 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ca1d10c363
commit
eab903ecad
2 changed files with 21 additions and 18 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2004-02-07 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSKeyedUnarchiver.m: Changes to fix memory leaks.
|
||||||
|
Fix bug handling nil/NSnull reported by Fred.
|
||||||
|
|
||||||
2004-02-06 Richard Frith-Macdonald <rfm@gnu.org>
|
2004-02-06 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/GSHTTPURLHandle.m: If there is no path in the URL, assume '/'
|
* Source/GSHTTPURLHandle.m: If there is no path in the URL, assume '/'
|
||||||
|
|
|
@ -34,9 +34,9 @@
|
||||||
/*
|
/*
|
||||||
* Setup for inline operation of arrays.
|
* Setup for inline operation of arrays.
|
||||||
*/
|
*/
|
||||||
#define GSI_ARRAY_RETAIN(A, X)
|
#define GSI_ARRAY_RETAIN(A, X) RETAIN((X).obj)
|
||||||
#define GSI_ARRAY_RELEASE(A, X)
|
#define GSI_ARRAY_RELEASE(A, X) RELEASE((X).obj)
|
||||||
#define GSI_ARRAY_TYPES GSUNION_OBJ|GSUNION_SEL|GSUNION_PTR
|
#define GSI_ARRAY_TYPES GSUNION_OBJ
|
||||||
|
|
||||||
|
|
||||||
#include <GNUstepBase/GSIArray.h>
|
#include <GNUstepBase/GSIArray.h>
|
||||||
|
@ -191,7 +191,6 @@ static NSMapTable globalClassMap = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
savedCursor = _cursor;
|
savedCursor = _cursor;
|
||||||
savedKeyMap = _keyMap;
|
savedKeyMap = _keyMap;
|
||||||
|
|
||||||
|
@ -199,7 +198,7 @@ static NSMapTable globalClassMap = 0;
|
||||||
_keyMap = obj; // Dictionary describing object
|
_keyMap = obj; // Dictionary describing object
|
||||||
|
|
||||||
o = [c allocWithZone: _zone]; // Create instance.
|
o = [c allocWithZone: _zone]; // Create instance.
|
||||||
// Store object in map so that decoding of it cn be self refrential.
|
// Store object in map so that decoding of it can be self referential.
|
||||||
GSIArraySetItemAtIndex(_objMap, (GSIArrayItem)o, index);
|
GSIArraySetItemAtIndex(_objMap, (GSIArrayItem)o, index);
|
||||||
r = [o initWithCoder: self];
|
r = [o initWithCoder: self];
|
||||||
if (r != o)
|
if (r != o)
|
||||||
|
@ -232,25 +231,24 @@ static NSMapTable globalClassMap = 0;
|
||||||
GSIArraySetItemAtIndex(_objMap, (GSIArrayItem)o, index);
|
GSIArraySetItemAtIndex(_objMap, (GSIArrayItem)o, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
RELEASE(o); // Retained in array
|
||||||
if (o == nil)
|
obj = o;
|
||||||
{
|
|
||||||
obj = RETAIN(GSIArrayItemAtIndex(_objMap, 0).obj);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
obj = o;
|
|
||||||
}
|
|
||||||
|
|
||||||
_keyMap = savedKeyMap;
|
_keyMap = savedKeyMap;
|
||||||
_cursor = savedCursor;
|
_cursor = savedCursor;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RETAIN(obj); // Use the decoded object directly
|
// Use the decoded object directly
|
||||||
GSIArraySetItemAtIndex(_objMap, (GSIArrayItem)obj, index);
|
GSIArraySetItemAtIndex(_objMap, (GSIArrayItem)obj, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (obj == nil)
|
||||||
|
{
|
||||||
|
// Record NSNull marker for decoded object.
|
||||||
|
o = GSIArrayItemAtIndex(_objMap, 0).obj;
|
||||||
|
GSIArraySetItemAtIndex(_objMap, (GSIArrayItem)o, index);
|
||||||
|
}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
@ -764,11 +762,11 @@ static NSMapTable globalClassMap = 0;
|
||||||
count = [_objects count];
|
count = [_objects count];
|
||||||
GSIArrayInitWithZoneAndCapacity(_objMap, _zone, count);
|
GSIArrayInitWithZoneAndCapacity(_objMap, _zone, count);
|
||||||
// Add marker for nil object
|
// Add marker for nil object
|
||||||
GSIArrayAddItem(_objMap, (GSIArrayItem)(void*)[NSNull null]);
|
GSIArrayAddItem(_objMap, (GSIArrayItem)[NSNull null]);
|
||||||
// Add markers for unencoded objects.
|
// Add markers for unencoded objects.
|
||||||
for (i = 1; i < count; i++)
|
for (i = 1; i < count; i++)
|
||||||
{
|
{
|
||||||
GSIArrayAddItem(_objMap, (GSIArrayItem)(void*)0);
|
GSIArrayAddItem(_objMap, (GSIArrayItem)nil);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue