Skip to content

Commit

Permalink
Merge branch 'master' into weakref
Browse files Browse the repository at this point in the history
  • Loading branch information
rfm committed Dec 30, 2024
2 parents 502d195 + 970e5a3 commit b90d591
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 27 deletions.
Binary file modified NSTimeZones/NSTimeZones.tar
Binary file not shown.
14 changes: 7 additions & 7 deletions Source/Additions/NSObject+GNUstepBase.m
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,8 @@ + (BOOL) shouldCleanUp
}
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
Expand Down Expand Up @@ -598,7 +598,7 @@ - (void) _replacementDealloc
}
}
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);
}
Expand All @@ -620,7 +620,7 @@ - (void) _replacementRelease
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);
}
Expand All @@ -644,7 +644,7 @@ - (id) _replacementRetain

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;
Expand Down Expand Up @@ -755,7 +755,7 @@ + (void) trackOwnership
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));
}

Expand Down Expand Up @@ -823,7 +823,7 @@ - (void) trackOwnership
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));
}

Expand Down
61 changes: 42 additions & 19 deletions Source/NSPropertyList.m
Original file line number Diff line number Diff line change
Expand Up @@ -2379,30 +2379,46 @@ @implementation NSPropertyListSerialization

+ (void) initialize
{
if (classInitialized == NO)
{
NSMutableCharacterSet *s;
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];
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)
{
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.
*/
Expand All @@ -2413,7 +2429,10 @@ + (void) initialize
[s invert];
oldQuotables = s;
[[NSObject leakAt: &oldQuotables] release];
}

if (nil == xmlQuotables)
{
s = [NSMutableCharacterSet new];
[s addCharactersInString: @"&<>'\\\""];
[s addCharactersInRange: NSMakeRange(0x0001, 0x001f)];
Expand All @@ -2423,13 +2442,17 @@ + (void) initialize
[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
Expand Down
5 changes: 4 additions & 1 deletion Source/NSTimeZone.m
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,6 @@ + (void) atExit
GS_MUTEX_UNLOCK(zone_mutex);

DESTROY(zoneDictionary);
DESTROY(localTimeZone);
DESTROY(defaultTimeZone);
DESTROY(systemTimeZone);
DESTROY(abbreviationDictionary);
Expand Down Expand Up @@ -1346,6 +1345,10 @@ + (void) initialize
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
Expand Down

0 comments on commit b90d591

Please sign in to comment.