Merge branch 'master' into weakref

This commit is contained in:
rfm 2024-12-30 13:02:23 +00:00
commit b90d591dfe
4 changed files with 55 additions and 29 deletions

Binary file not shown.

View file

@ -541,8 +541,8 @@ findMethods(id o, IMP *dea, IMP *rel, IMP *ret)
}
GS_MUTEX_UNLOCK(trackLock);
fprintf(stderr, "Tracking ownership - unable to find entry for"
" instance %p of '%s'\n", o, class_getName(c));
NSLog(@"Tracking ownership %p problem at %s",
" instance %p of '%s'.\n", o, class_getName(c));
fprintf(stderr, "Tracking ownership %p problem at %s.\n",
o, stackTrace(1));
/* Should never happen because we don't remove class entries, but I suppose
@ -598,7 +598,7 @@ findMethods(id o, IMP *dea, IMP *rel, IMP *ret)
}
}
GS_MUTEX_UNLOCK(trackLock);
NSLog(@"Tracking ownership -[%p dealloc] at %s",
fprintf(stderr, "Tracking ownership -[%p dealloc] at %s.\n",
self, stackTrace(2));
(*dealloc)(self, _cmd);
}
@ -620,7 +620,7 @@ findMethods(id o, IMP *dea, IMP *rel, IMP *ret)
unsigned rc;
rc = (unsigned)[self retainCount];
NSLog(@"Tracking ownership -[%p release] %u->%u at %s",
fprintf(stderr, "Tracking ownership -[%p release] %u->%u at %s.\n",
self, rc, rc-1, stackTrace(2));
(*release)(self, _cmd);
}
@ -644,7 +644,7 @@ findMethods(id o, IMP *dea, IMP *rel, IMP *ret)
rc = (unsigned)[self retainCount];
result = (*retain)(self, _cmd);
NSLog(@"Tracking ownership -[%p retain] %u->%u at %s",
fprintf(stderr, "Tracking ownership -[%p retain] %u->%u at %s.\n",
self, rc, (unsigned)[self retainCount], stackTrace(2));
}
return result;
@ -755,7 +755,7 @@ makeLinkForClass(Class c)
l->next = tracked;
tracked = l;
GS_MUTEX_UNLOCK(trackLock);
NSLog(@"Tracking ownership started for class %p at %s",
fprintf(stderr, "Tracking ownership started for class %p at %s.\n",
self, stackTrace(1));
}
@ -823,7 +823,7 @@ makeLinkForClass(Class c)
li->next = tracked;
tracked = li;
GS_MUTEX_UNLOCK(trackLock);
NSLog(@"Tracking ownership started for instance %p at %s",
fprintf(stderr, "Tracking ownership started for instance %p at %s.\n",
self, stackTrace(1));
}

View file

@ -2379,30 +2379,46 @@ static BOOL classInitialized = NO;
+ (void) initialize
{
if (classInitialized == NO)
NSMutableCharacterSet *s;
if (Nil == NSStringClass) NSStringClass = [NSString class];
if (Nil == GSStringClass) GSStringClass = [GSString class];
if (Nil == NSMutableStringClass)
NSMutableStringClass = [NSMutableString class];
if (Nil == GSMutableStringClass)
GSMutableStringClass = [GSMutableString class];
if (Nil == NSArrayClass) NSArrayClass = [NSArray class];
if (Nil == plArray)
{
NSMutableCharacterSet *s;
classInitialized = YES;
NSStringClass = [NSString class];
NSMutableStringClass = [NSMutableString class];
NSDataClass = [NSData class];
NSDateClass = [NSDate class];
NSNumberClass = [NSNumber class];
NSArrayClass = [NSArray class];
NSDictionaryClass = [NSDictionary class];
GSStringClass = [GSString class];
GSMutableStringClass = [GSMutableString class];
plArray = [GSMutableArray class];
plAdd = (id (*)(id, SEL, id))
[plArray instanceMethodForSelector: @selector(addObject:)];
}
if (Nil == NSDictionaryClass) NSDictionaryClass = [NSDictionary class];
if (Nil == plDictionary)
{
plDictionary = [GSMutableDictionary class];
plSet = (id (*)(id, SEL, id, id))
[plDictionary instanceMethodForSelector: @selector(setObject:forKey:)];
}
if (Nil == NSDataClass) NSDataClass = [NSData class];
if (Nil == NSNumberClass) NSNumberClass = [NSNumber class];
if (nil == boolN)
{
boolN = [[NSNumber numberWithBool: NO] retain];
[[NSObject leakAt: &boolN] release];
}
if (nil == boolY)
{
boolY = [[NSNumber numberWithBool: YES] retain];
[[NSObject leakAt: &boolY] release];
}
if (nil == oldQuotables)
{
/* The '$', '.', '/' and '_' characters used to be OK to use in
* property lists, but OSX now quotes them, so we follow suite.
*/
@ -2413,7 +2429,10 @@ static BOOL classInitialized = NO;
[s invert];
oldQuotables = s;
[[NSObject leakAt: &oldQuotables] release];
}
if (nil == xmlQuotables)
{
s = [NSMutableCharacterSet new];
[s addCharactersInString: @"&<>'\\\""];
[s addCharactersInRange: NSMakeRange(0x0001, 0x001f)];
@ -2423,13 +2442,17 @@ static BOOL classInitialized = NO;
[s addCharactersInRange: NSMakeRange(0xFFFE, 0x0002)];
xmlQuotables = s;
[[NSObject leakAt: &xmlQuotables] release];
boolN = [[NSNumber numberWithBool: NO] retain];
[[NSObject leakAt: &boolN] release];
boolY = [[NSNumber numberWithBool: YES] retain];
[[NSObject leakAt: &boolY] release];
}
/* Initialize the date class last as it has external dependencies on
* time zone data.
*/
if (Nil == NSDateClass)
{
NSDateClass = [NSDate class];
}
classInitialized = YES;
}
+ (NSData*) dataFromPropertyList: (id)aPropertyList

View file

@ -1288,7 +1288,6 @@ static int uninitialisedOffset = 100000;
GS_MUTEX_UNLOCK(zone_mutex);
DESTROY(zoneDictionary);
DESTROY(localTimeZone);
DESTROY(defaultTimeZone);
DESTROY(systemTimeZone);
DESTROY(abbreviationDictionary);
@ -1346,6 +1345,10 @@ static int uninitialisedOffset = 100000;
absolutes = NSCreateMapTable(NSIntegerMapKeyCallBacks,
NSNonOwnedPointerMapValueCallBacks, 0);
/* NB. the instance of NSLocalTimeZone overrides memory management
* so it is never deallocated. This must not be destroyed in the
* +atExit: method becuse that would confuse leak analysis tools.
*/
localTimeZone = [[NSLocalTimeZone alloc] init];
[[NSNotificationCenter defaultCenter] addObserver: self