leak detection improvements

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37003 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2013-08-22 15:44:54 +00:00
parent edc02cf9e5
commit 1483924463
102 changed files with 429 additions and 235 deletions

109
ChangeLog
View file

@ -1,3 +1,112 @@
2013-08-22 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSIndexPath.m:
* Source/NSMapTable.m:
* Source/NSSocketPortNameServer.m:
* Source/GSLocale.m:
* Source/NSNetServices.m:
* Source/NSTimeZone.m:
* Source/NSHashTable.m:
* Source/GSSocketStream.m:
* Source/NSValueTransformer.m:
* Source/NSBundle.m:
* Source/NSURLHandle.m:
* Source/NSPropertyList.m:
* Source/NSAffineTransform.m:
* Source/NSPathUtilities.m:
* Source/NSScanner.m:
* Source/NSDistributedNotificationCenter.m:
* Source/NSProcessInfo.m:
* Source/NSNotificationQueue.m:
* Source/NSSocketPort.m:
* Source/NSAttributedString.m:
* Source/NSRunLoop.m:
* Source/NSOperation.m:
* Source/NSObject+NSComparisonMethods.m:
* Source/NSFormatter.m:
* Source/NSUserDefaults.m:
* Source/NSArray.m:
* Source/NSMessagePortNameServer.m:
* Source/GSStream.m:
* Source/NSKeyedArchiver.m:
* Source/NSDebug.m:
* Source/NSXMLPrivate.h:
* Source/NSKeyedUnarchiver.m:
* Source/NSPortMessage.m:
* Source/NSFileHandle.m:
* Source/NSDistributedLock.m:
* Source/GSTLS.m:
* Source/NSPredicate.m:
* Source/NSKeyValueObserving.m:
* Source/NSAssertionHandler.m:
* Source/GSHTTPURLHandle.m:
* Source/GSDispatch.h:
* Source/NSPort.m:
* Source/NSSortDescriptor.m:
* Source/NSMessagePort.m:
* Source/win32/NSMessagePort.m:
* Source/win32/NSMessagePortNameServer.m:
* Source/NSInvocation.m:
* Source/NSFileManager.m:
* Source/common.h:
* Source/NSURLProtocol.m:
* Source/NSURLCache.m:
* Source/NSNotificationCenter.m:
* Source/GSAttributedString.m:
* Source/externs.m:
* Source/NSCoder.m:
* Source/NSHTTPCookieStorage.m:
* Source/NSURL.m:
* Source/NSString.m:
* Source/NSObject.m:
* Source/NSDecimalNumber.m:
* Source/NSConcreteMapTable.m:
* Source/NSPointerFunctions.m:
* Source/GSSorting.h:
* Source/NSPointerArray.m:
* Source/Additions/GCObject.m:
* Source/Additions/GSMime.m:
* Source/Additions/NSObject+GNUstepBase.m:
* Source/Additions/GSXML.m:
* Source/Additions/GSObjCRuntime.m:
* Source/NSNotification.m:
* Source/NSNumber.m:
* Source/GSTimSort.m:
* Source/NSConnection.m:
* Source/GSString.m:
* Source/NSHTTPCookie.m:
* Source/NSData.m:
* Source/NSHost.m:
* Source/NSDate.m:
* Source/NSMetadata.m:
* Source/NSDictionary.m:
* Source/GSMDNSNetServices.m:
* Source/GSHTTPAuthentication.m:
* Source/NSClassDescription.m:
* Source/NSSerializer.m:
* Source/NSNull.m:
* Source/NSValue.m:
* Source/NSCountedSet.m:
* Source/GSFileHandle.h:
* Source/GSFileHandle.m:
* Source/NSLock.m:
* Source/NSSet.m:
* Source/NSLocale.m:
* Source/NSTask.m:
* Source/NSJSONSerialization.m:
* Source/NSCharacterSet.m:
* Source/NSPortNameServer.m:
* Source/NSXMLParser.m:
* Source/NSConcreteHashTable.m:
* Source/NSTextCheckingResult.m:
* Source/NSEnumerator.m:
* Source/GSFTPURLHandle.m:
Improve atExit/leak handling to be executed with a thread and an
autorelease pool in place.
Record as deliberately 'leaked', objects created in +initialize
methods and intended to persist until exit.
Fix a couple of bugs exposed by turning on clean up of leaked objects.
2013-08-14 Lubos Dolezel <lubos@dolezel.info>
* Source/NSBundle.m: add NSBundle pathForAuxiliaryExecutable: and

View file

@ -226,6 +226,7 @@ static pthread_mutex_t *allocationLock = NULL;
{
allObjects = (_GCObjectList*)
NSAllocateObject([_GCObjectList class], 0, NSDefaultMallocZone());
[[NSObject leakAt: &allObjects] release];
allObjects->gc.next = allObjects;
allObjects->gc.previous = allObjects;
if ([NSThread isMultiThreaded] == YES)

View file

@ -3282,8 +3282,10 @@ static NSCharacterSet *tokenSet = nil;
[ms addCharactersInRange: NSMakeRange(33, 126-32)];
[ms removeCharactersInString: @"()<>@,;:\\\"/[]?="];
tokenSet = [ms copy];
[[NSObject leakAt: &tokenSet] release];
RELEASE(ms);
nonToken = RETAIN([tokenSet invertedSet]);
[[NSObject leakAt: &nonToken] release];
if (NSArrayClass == 0)
{
NSArrayClass = [NSArray class];
@ -4438,13 +4440,16 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
[m formUnionWithCharacterSet:
[NSCharacterSet illegalCharacterSet]];
rfc822Specials = [m copy];
[[NSObject leakAt: &rfc822Specials] release];
[m formUnionWithCharacterSet:
[NSCharacterSet characterSetWithCharactersInString:
@"/?="]];
[m removeCharactersInString: @"."];
rfc2045Specials = [m copy];
[[NSObject leakAt: &rfc2045Specials] release];
[m release];
whitespace = RETAIN([NSCharacterSet whitespaceAndNewlineCharacterSet]);
[[NSObject leakAt: &whitespace] release];
if (NSArrayClass == 0)
{
NSArrayClass = [NSArray class];
@ -4457,6 +4462,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
{
charsets = NSCreateMapTable (NSObjectMapKeyCallBacks,
NSIntegerMapValueCallBacks, 0);
[[NSObject leakAt: &charsets] release];
/*
* These mappings were obtained primarily from
@ -4738,6 +4744,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
{
encodings = NSCreateMapTable (NSIntegerMapKeyCallBacks,
NSObjectMapValueCallBacks, 0);
[[NSObject leakAt: &encodings] release];
/* While the charset mappings above are many to one,
* mapping a variety of names to one encoding,

View file

@ -45,6 +45,7 @@
#import "Foundation/NSValue.h"
#endif
#import "GNUstepBase/GSObjCRuntime.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "../GSPrivate.h"

View file

@ -53,7 +53,7 @@
// #undef HAVE_LIBXML_SAX2_H
#import "GNUstepBase/GSObjCRuntime.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GNUstepBase/GSMime.h"
#import "GNUstepBase/GSXML.h"
#import "Foundation/NSArray.h"
@ -232,6 +232,7 @@ static NSMapTable *attrNames = 0;
setupCache();
attrNames = NSCreateMapTable(NSIntegerMapKeyCallBacks,
NSNonRetainedObjectMapValueCallBacks, 0);
[[NSObject leakAt: &attrNames] release];
NSMapInsert(attrNames,
(void*)XML_ATTRIBUTE_CDATA, (void*)@"XML_ATTRIBUTE_CDATA");
NSMapInsert(attrNames,
@ -598,6 +599,7 @@ static NSMapTable *nsNames = 0;
setupCache();
nsNames = NSCreateMapTable(NSIntegerMapKeyCallBacks,
NSNonRetainedObjectMapValueCallBacks, 0);
[[NSObject leakAt: &nsNames] release];
NSMapInsert(nsNames,
(void*)XML_LOCAL_NAMESPACE, (void*)@"XML_LOCAL_NAMESPACE");
}
@ -776,6 +778,7 @@ static NSMapTable *nodeNames = 0;
setupCache();
nodeNames = NSCreateMapTable(NSIntegerMapKeyCallBacks,
NSNonRetainedObjectMapValueCallBacks, 0);
[[NSObject leakAt: &nodeNames] release];
NSMapInsert(nodeNames,
(void*)XML_ELEMENT_NODE, (void*)@"XML_ELEMENT_NODE");
NSMapInsert(nodeNames,

View file

@ -28,6 +28,7 @@
#import "Foundation/NSLock.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GNUstepBase/NSDebug+GNUstepBase.h"
#import "GNUstepBase/NSThread+GNUstepBase.h"
/**
* Extension methods for the NSObject class
@ -142,6 +143,9 @@ static BOOL shouldCleanUp = NO;
static void
handleExit()
{
BOOL unknownThread = GSRegisterCurrentThread();
CREATE_AUTORELEASE_POOL(arp);
while (exited != 0)
{
struct exitLink *tmp = exited;
@ -170,7 +174,11 @@ handleExit()
}
free(tmp);
}
DESTROY(arp);
if (unknownThread == YES)
{
GSUnregisterCurrentThread();
}
}
@implementation NSObject(GSCleanup)

View file

@ -275,49 +275,6 @@ static void (*remImp)(NSMutableArray*,SEL,unsigned);
#define OBJECTAT(I) ((*oatImp)(_infoArray, oatSel, (I)))
#define REMOVEAT(I) ((*remImp)(_infoArray, remSel, (I)))
static void _setup(void)
{
if (infCls == 0)
{
NSMutableArray *a;
NSDictionary *d;
#if GS_WITH_GC
/* We create a typed memory descriptor for map nodes.
* Only the pointer to the key needs to be scanned.
*/
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
#endif
GSIMapInitWithZoneAndCapacity(&attrMap, NSDefaultMallocZone(), 32);
infSel = @selector(newWithZone:value:at:);
addSel = @selector(addObject:);
cntSel = @selector(count);
insSel = @selector(insertObject:atIndex:);
oatSel = @selector(objectAtIndex:);
remSel = @selector(removeObjectAtIndex:);
infCls = [GSAttrInfo class];
infImp = [infCls methodForSelector: infSel];
a = [NSMutableArray allocWithZone: NSDefaultMallocZone()];
a = [a initWithCapacity: 1];
addImp = (void (*)(NSMutableArray*,SEL,id))[a methodForSelector: addSel];
cntImp = (unsigned (*)(NSArray*,SEL))[a methodForSelector: cntSel];
insImp = (void (*)(NSMutableArray*,SEL,id,unsigned))
[a methodForSelector: insSel];
oatImp = [a methodForSelector: oatSel];
remImp = (void (*)(NSMutableArray*,SEL,unsigned))
[a methodForSelector: remSel];
RELEASE(a);
d = [NSDictionary new];
blank = cacheAttributes(d);
RELEASE(d);
}
}
static void
_setAttributesFrom(
NSAttributedString *attributedString,
@ -447,9 +404,48 @@ _attributesAtIndexEffectiveRange(
+ (void) initialize
{
_setup();
if (infCls == 0)
{
NSMutableArray *a;
NSDictionary *d;
#if GS_WITH_GC
/* We create a typed memory descriptor for map nodes.
* Only the pointer to the key needs to be scanned.
*/
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
#endif
GSIMapInitWithZoneAndCapacity(&attrMap, NSDefaultMallocZone(), 32);
infSel = @selector(newWithZone:value:at:);
addSel = @selector(addObject:);
cntSel = @selector(count);
insSel = @selector(insertObject:atIndex:);
oatSel = @selector(objectAtIndex:);
remSel = @selector(removeObjectAtIndex:);
infCls = [GSAttrInfo class];
infImp = [infCls methodForSelector: infSel];
a = [NSMutableArray allocWithZone: NSDefaultMallocZone()];
a = [a initWithCapacity: 1];
addImp = (void (*)(NSMutableArray*,SEL,id))[a methodForSelector: addSel];
cntImp = (unsigned (*)(NSArray*,SEL))[a methodForSelector: cntSel];
insImp = (void (*)(NSMutableArray*,SEL,id,unsigned))
[a methodForSelector: insSel];
oatImp = [a methodForSelector: oatSel];
remImp = (void (*)(NSMutableArray*,SEL,unsigned))
[a methodForSelector: remSel];
RELEASE(a);
d = [NSDictionary new];
blank = cacheAttributes(d);
[[NSObject leakAt: &blank] release];
RELEASE(d);
}
attrLock = [GSLazyLock new];
[[NSObject leakAt: &attrLock] release];
lockSel = @selector(lock);
unlockSel = @selector(unlock);
lockImp = [attrLock methodForSelector: lockSel];

View file

@ -22,8 +22,8 @@
Boston, MA 02111 USA.
*/
#import "GNUstepBase/GSConfig.h"
#import <GNUstepBase/GSBlocks.h>
#import "GNUstepBase/GSBlocks.h"
#if HAVE_DISPATCH_H
#include <dispatch.h>
#elif HAVE_DISPATCH_DISPATCH_H
@ -40,8 +40,8 @@
#if __has_feature(blocks) && (GS_USE_LIBDISPATCH == 1)
/*
* Older versions of libdispatch do not support concurrent queues. We define away the
* attributes in this case.
* Older versions of libdispatch do not support concurrent queues.
* We define away the attributes in this case.
*/
#ifndef DISPATCH_QUEUE_SERIAL
#define DISPATCH_QUEUE_SERIAL NULL

View file

@ -540,7 +540,9 @@ static NSLock *urlLock = nil;
if (self == [GSFTPURLHandle class])
{
urlCache = [NSMutableDictionary new];
[[NSObject leakAt: &urlCache] release];
urlLock = [NSLock new];
[[NSObject leakAt: &urlLock] release];
}
}

View file

@ -25,12 +25,11 @@
#ifndef __GSFileHandle_h_GNUSTEP_BASE_INCLUDE
#define __GSFileHandle_h_GNUSTEP_BASE_INCLUDE
#import <Foundation/NSFileHandle.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSRunLoop.h>
#import "Foundation/NSFileHandle.h"
#import "Foundation/NSArray.h"
#import "Foundation/NSDictionary.h"
#import "Foundation/NSRunLoop.h"
#import <GNUstepBase/GSConfig.h>
#if USE_ZLIB
#include <zlib.h>

View file

@ -40,7 +40,6 @@
#import "Foundation/NSUserDefaults.h"
#import "GSPrivate.h"
#import "GSNetwork.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GSFileHandle.h"
#import "../Tools/gdomap.h"

View file

@ -31,7 +31,6 @@
#import "Foundation/NSValue.h"
#import "GNUstepBase/GSLock.h"
#import "GNUstepBase/GSMime.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GNUstepBase/NSData+GNUstepBase.h"
@ -87,10 +86,15 @@ static GSMimeParser *mimeParser = nil;
if (store == nil)
{
mimeParser = [GSMimeParser new];
[[NSObject leakAt: &mimeParser] release];
spaces = [NSMutableSet new];
[[NSObject leakAt: &spaces] release];
domainMap = [NSMutableDictionary new];
[[NSObject leakAt: &domainMap] release];
store = [NSMutableDictionary new];
[[NSObject leakAt: &store] release];
storeLock = [GSLazyLock new];
[[NSObject leakAt: &storeLock] release];
}
}

View file

@ -272,8 +272,11 @@ debugWrite(GSHTTPURLHandle *handle, NSData *data)
if (self == [GSHTTPURLHandle class])
{
urlCache = [NSMutableDictionary new];
[[NSObject leakAt: &urlCache] release];
urlOrder = [NSMutableArray new];
[[NSObject leakAt: &urlOrder] release];
urlLock = [GSLazyLock new];
[[NSObject leakAt: &urlLock] release];
#if !defined(__MINGW__)
sslClass = [NSFileHandle sslClass];
#endif

View file

@ -24,7 +24,6 @@
*/
#import "common.h"
#import "GNUstepBase/GSLocale.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "Foundation/NSDictionary.h"
#import "Foundation/NSArray.h"
#import "Foundation/NSLock.h"

View file

@ -32,7 +32,6 @@
#import "Foundation/NSRunLoop.h"
#import "Foundation/NSTimer.h"
#import "Foundation/NSValue.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#if defined(_REENTRANT)
#import "GNUstepBase/GSLock.h"
#endif

View file

@ -40,7 +40,6 @@
#import "GSPrivate.h"
#import "GSStream.h"
#import "GSSocketStream.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GSTLS.h"
@ -440,6 +439,7 @@ static NSArray *keys = nil;
GSTLSRevokeFile,
GSTLSVerify,
nil];
[[NSObject leakAt: &keys] release];
}
}

View file

@ -25,7 +25,6 @@
#import "Foundation/NSSortDescriptor.h"
#import "GNUstepBase/GSObjCRuntime.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "Foundation/NSException.h"
#import "GSPrivate.h"

View file

@ -37,7 +37,6 @@
#import "GSStream.h"
#import "GSPrivate.h"
#import "GSSocketStream.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
NSString * const NSStreamDataWrittenToMemoryStreamKey
= @"NSStreamDataWrittenToMemoryStreamKey";

View file

@ -44,7 +44,6 @@
#import "Foundation/NSValue.h"
#import "Foundation/NSKeyedArchiver.h"
#import "GNUstepBase/GSObjCRuntime.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GSPrivate.h"

View file

@ -411,8 +411,10 @@ static GSTLSDHParams *paramsCurrent = nil;
if (nil == paramsLock)
{
paramsLock = [NSLock new];
[[NSObject leakAt: &paramsLock] release];
paramsWhen = [NSDate timeIntervalSinceReferenceDate];
paramsCache = [NSMutableDictionary new];
[[NSObject leakAt: &paramsCache] release];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(housekeeping:)
name: @"GSHousekeeping" object: nil];
@ -597,7 +599,9 @@ static NSMutableDictionary *certificateListCache = nil;
if (nil == certificateListLock)
{
certificateListLock = [NSLock new];
[[NSObject leakAt: &certificateListLock] release];
certificateListCache = [NSMutableDictionary new];
[[NSObject leakAt: &certificateListCache] release];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(housekeeping:)
name: @"GSHousekeeping" object: nil];
@ -779,8 +783,11 @@ static NSMutableDictionary *privateKeyCache1 = nil;
if (nil == privateKeyLock)
{
privateKeyLock = [NSLock new];
[[NSObject leakAt: &privateKeyLock] release];
privateKeyCache0 = [NSMutableDictionary new];
[[NSObject leakAt: &privateKeyCache0] release];
privateKeyCache1 = [NSMutableDictionary new];
[[NSObject leakAt: &privateKeyCache1] release];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(housekeeping:)
@ -933,7 +940,9 @@ static NSMutableDictionary *credentialsCache = nil;
if (nil == credentialsLock)
{
credentialsLock = [NSLock new];
[[NSObject leakAt: &credentialsLock] release];
credentialsCache = [NSMutableDictionary new];
[[NSObject leakAt: &credentialsCache] release];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(housekeeping:)

View file

@ -30,7 +30,6 @@
#import "Foundation/NSKeyValueCoding.h"
#import "GNUstepBase/GSObjCRuntime.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GSPrivate.h"
#import "GSSorting.h"

View file

@ -39,7 +39,6 @@
#import "Foundation/NSException.h"
#import "Foundation/NSAffineTransform.h"
#import "Foundation/NSCoder.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
/* Private definitions */
#define A _matrix.m11

View file

@ -49,7 +49,6 @@
#import "Foundation/NSIndexSet.h"
// For private method _decodeArrayOfObjectsForKey:
#import "Foundation/NSKeyedArchiver.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GSPrivate.h"
#import "GSFastEnumeration.h"
#import "GSDispatch.h"

View file

@ -26,7 +26,6 @@
*/
#import "common.h"
#import "GNUstepBase/GSConfig.h"
#import "Foundation/NSException.h"
#import "Foundation/NSDictionary.h"
#import "Foundation/NSThread.h"

View file

@ -56,7 +56,6 @@
#import "Foundation/NSAutoreleasePool.h"
#import "Foundation/NSPortCoder.h"
#import "Foundation/NSRange.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
@class GSAttributedString;
@interface GSAttributedString : NSObject // Help the compiler

View file

@ -51,7 +51,6 @@
#import "Foundation/NSData.h"
#import "Foundation/NSURL.h"
#import "Foundation/NSValue.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GNUstepBase/NSString+GNUstepBase.h"
#import "GSPrivate.h"
@ -69,6 +68,7 @@ manager()
if (mgr == nil)
{
mgr = RETAIN([NSFileManager defaultManager]);
[[NSObject leakAt: &mgr] release];
}
return mgr;
}
@ -1054,6 +1054,29 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
@implementation NSBundle
+ (void) atExit
{
if ([NSObject shouldCleanUp])
{
DESTROY(_emptyTable);
DESTROY(langAliases);
DESTROY(langCanonical);
DESTROY(_bundles);
DESTROY(_byClass);
DESTROY(_byIdentifier);
DESTROY(pathCache);
DESTROY(pathCacheLock);
DESTROY(load_lock);
DESTROY(gnustep_target_cpu);
DESTROY(gnustep_target_os);
DESTROY(gnustep_target_dir);
DESTROY(library_combo);
DESTROY(_launchDirectory);
DESTROY(_gnustep_bundle);
DESTROY(_mainBundle);
}
}
+ (void) initialize
{
if (self == [NSBundle class])
@ -1227,6 +1250,7 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
#endif
GSPathHandling(mode);
[pool release];
[self registerAtExit];
}
}

View file

@ -39,7 +39,6 @@
#import "Foundation/NSNotification.h"
#import "Foundation/NSCharacterSet.h"
#import "Foundation/NSData.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
/* Using and index set to hold a characterset is more space efficient but
* on the intel core-2 system I benchmarked on, it made my applications
@ -637,9 +636,9 @@ static Class concreteMutableClass = nil;
+ (void) initialize
{
static BOOL one_time = NO;
static BOOL beenHere = NO;
if (one_time == NO)
if (beenHere == NO)
{
abstractClass = [NSCharacterSet class];
abstractMutableClass = [NSMutableCharacterSet class];
@ -650,9 +649,10 @@ static Class concreteMutableClass = nil;
concreteClass = [NSBitmapCharSet class];
concreteMutableClass = [NSMutableBitmapCharSet class];
#endif
one_time = YES;
cache_lock = [GSLazyLock new];
[[NSObject leakAt: &cache_lock] release];
beenHere = YES;
}
cache_lock = [GSLazyLock new];
}
/**
@ -674,6 +674,7 @@ static Class concreteMutableClass = nil;
freeWhenDone: NO];
cache_set[number]
= [[_GSStaticCharSet alloc] initWithBitmap: bitmap number: number];
[[NSObject leakAt: &cache_set[number]] release];
RELEASE(bitmap);
}
[cache_lock unlock];

View file

@ -87,7 +87,9 @@ static NSMapTable *classMap;
{
classMap = NSCreateMapTable(NSObjectMapKeyCallBacks,
NSObjectMapValueCallBacks, 100);
[[NSObject leakAt: &classMap] release];
mapLock = [NSRecursiveLock new];
[[NSObject leakAt: &mapLock] release];
}
}

View file

@ -37,7 +37,6 @@
#import "Foundation/NSCoder.h"
#import "Foundation/NSSerialization.h"
#import "Foundation/NSUserDefaults.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
@implementation NSCoder

View file

@ -38,7 +38,6 @@
#import "NSConcretePointerFunctions.h"
#import "NSCallBacks.h"
#import "GSPrivate.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
static Class concreteClass = Nil;

View file

@ -37,7 +37,6 @@
#import "NSConcretePointerFunctions.h"
#import "NSCallBacks.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
static Class concreteClass = Nil;

View file

@ -81,7 +81,6 @@
#import "Foundation/NSEnumerator.h"
#import "GNUstepBase/GSLock.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
/* Skip past an argument and also any offset information before the next.
*/
@ -661,29 +660,36 @@ static NSLock *cached_proxies_gate = nil;
runLoopClass = [NSRunLoop class];
dummyObject = [NSObject new];
[[NSObject leakAt: &dummyObject] release];
connection_table =
NSCreateHashTable(NSNonRetainedObjectHashCallBacks, 0);
[[NSObject leakAt: &connection_table] release];
targetToCached =
NSCreateMapTable(NSIntegerMapKeyCallBacks,
NSObjectMapValueCallBacks, 0);
[[NSObject leakAt: &targetToCached] release];
root_object_map =
NSCreateMapTable(NSNonOwnedPointerMapKeyCallBacks,
NSObjectMapValueCallBacks, 0);
[[NSObject leakAt: &root_object_map] release];
if (connection_table_gate == nil)
{
connection_table_gate = [GSLazyRecursiveLock new];
[[NSObject leakAt: &connection_table_gate] release];
}
if (cached_proxies_gate == nil)
{
cached_proxies_gate = [GSLazyLock new];
[[NSObject leakAt: &cached_proxies_gate] release];
}
if (root_object_map_gate == nil)
{
root_object_map_gate = [GSLazyLock new];
[[NSObject leakAt: &root_object_map_gate] release];
}
/*

View file

@ -34,7 +34,6 @@
#import "Foundation/NSLock.h"
#import "Foundation/NSNotification.h"
#import "Foundation/NSThread.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
@class GSCountedSet;
@interface GSCountedSet : NSObject // Help the compiler
@ -74,6 +73,7 @@ static Class NSCountedSet_concrete_class;
NSCountedSet_abstract_class = self;
NSCountedSet_concrete_class = [GSCountedSet class];
uniqueLock = [GSLazyRecursiveLock new];
[[NSObject leakAt: &uniqueLock] release];
lockImp = [uniqueLock methodForSelector: @selector(lock)];
unlockImp = [uniqueLock methodForSelector: @selector(unlock)];
}

View file

@ -84,7 +84,6 @@
#import "Foundation/NSURL.h"
#import "Foundation/NSValue.h"
#import "GSPrivate.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#include <stdio.h>
#ifdef HAVE_MMAP

View file

@ -40,7 +40,6 @@
#import "Foundation/NSTimeZone.h"
#import "Foundation/NSUserDefaults.h"
#import "GNUstepBase/GSObjCRuntime.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GSPrivate.h"

View file

@ -87,6 +87,7 @@ static void (*_GSDebugAllocationRemoveFunc)(Class c, id o)
+ (void) initialize
{
uniqueLock = [GSLazyRecursiveLock new];
[[NSObject leakAt: &uniqueLock] release];
}
@end

View file

@ -171,16 +171,21 @@ static NSDecimalNumber *one;
NSDecimal d = { 0 };
notANumber = [[self alloc] initWithDecimal: d];
[[NSObject leakAt: &notANumber] release];
NSDecimalMax(&d);
maxNumber = [[self alloc] initWithDecimal: d];
[[NSObject leakAt: &maxNumber] release];
NSDecimalMin(&d);
minNumber = [[self alloc] initWithDecimal: d];
[[NSObject leakAt: &minNumber] release];
zero = [[self alloc] initWithMantissa: 0
exponent: 0
isNegative: NO];
[[NSObject leakAt: &zero] release];
one = [[self alloc] initWithMantissa: 1
exponent: 0
isNegative: NO];
[[NSObject leakAt: &one] release];
NSDecimalNumberClass = [NSDecimalNumber class];
}

View file

@ -41,7 +41,6 @@
#import "Foundation/NSUserDefaults.h"
// For private method _decodeArrayOfObjectsForKey:
#import "Foundation/NSKeyedArchiver.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GSPrivate.h"
#import "GSFastEnumeration.h"
#import "GSDispatch.h"

View file

@ -55,6 +55,7 @@ static NSFileManager *mgr = nil;
if (mgr == nil)
{
mgr = RETAIN([NSFileManager defaultManager]);
[[NSObject leakAt: &mgr] release];
}
}

View file

@ -38,7 +38,6 @@
#import "Foundation/NSRunLoop.h"
#import "Foundation/NSTask.h"
#import "GNUstepBase/NSTask+GNUstepBase.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "Foundation/NSDistributedNotificationCenter.h"
#import "Foundation/NSUserDefaults.h"
#import "Foundation/NSHost.h"

View file

@ -29,7 +29,6 @@
#import "Foundation/NSArray.h"
#import "Foundation/NSEnumerator.h"
#import "Foundation/NSException.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
/**

View file

@ -32,7 +32,6 @@
#import "Foundation/NSHost.h"
#import "Foundation/NSFileHandle.h"
#import "Foundation/NSPathUtilities.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GNUstepBase/NSString+GNUstepBase.h"
#import "GSPrivate.h"
#import "GSNetwork.h"

View file

@ -61,7 +61,6 @@
#import "Foundation/NSURL.h"
#import "Foundation/NSValue.h"
#import "GSPrivate.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GNUstepBase/NSString+GNUstepBase.h"
#include <stdio.h>
@ -3143,6 +3142,7 @@ static NSSet *fileKeys = nil;
NSFileSystemNumber,
NSFileType,
nil];
[[NSObject leakAt: &fileKeys] release];
}
}

View file

@ -27,7 +27,6 @@
#import "common.h"
#import "Foundation/NSFormatter.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
@implementation NSFormatter

View file

@ -45,7 +45,6 @@
#import "Foundation/NSString.h"
#import "Foundation/NSCalendarDate.h"
#import "GNUstepBase/Unicode.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
NSString * const NSHTTPCookieComment = @"Comment";
NSString * const NSHTTPCookieCommentURL = @"CommentURL";

View file

@ -31,7 +31,6 @@
#import "Foundation/NSPathUtilities.h"
#import "Foundation/NSString.h"
#import "Foundation/NSDistributedNotificationCenter.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
NSString * const NSHTTPCookieManagerAcceptPolicyChangedNotification
= @"NSHTTPCookieManagerAcceptPolicyChangedNotification";

View file

@ -32,7 +32,6 @@
#import "Foundation/NSHashTable.h"
#import "NSCallBacks.h"
#import "GSPrivate.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
@interface NSConcreteHashTable : NSHashTable
@end

View file

@ -265,8 +265,11 @@ myHostName()
{
hostClass = self;
null = [[NSNull null] retain];
[[NSObject leakAt: &null] release];
_hostCacheLock = [[NSRecursiveLock alloc] init];
[[NSObject leakAt: &_hostCacheLock] release];
_hostCache = [NSMutableDictionary new];
[[NSObject leakAt: &_hostCache] release];
}
}

View file

@ -70,10 +70,14 @@ static NSIndexPath *dummy = nil;
{
myClass = self;
empty = (NSIndexPath*)NSAllocateObject(self, 0, NSDefaultMallocZone());
[[NSObject leakAt: &empty] release];
dummy = (NSIndexPath*)NSAllocateObject(self, 0, NSDefaultMallocZone());
[[NSObject leakAt: &dummy] release];
shared = NSCreateHashTable(NSNonRetainedObjectHashCallBacks, 1024);
[[NSObject leakAt: &shared] release];
NSHashInsert(shared, empty);
lock = [GSLazyRecursiveLock new];
[[NSObject leakAt: &lock] release];
}
}

View file

@ -35,7 +35,6 @@
#import "Foundation/NSZone.h"
#import "GSInvocation.h"
#import "GSPrivate.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#if defined(USE_LIBFFI)
#include "cifframe.h"

View file

@ -7,8 +7,18 @@
* data for the parse can be either a static JSON string or some JSON data.
*/
#import <Foundation/Foundation.h>
#import <GNUstepBase/NSObject+GNUstepBase.h>
#import "common.h"
#import "Foundation/NSArray.h"
#import "Foundation/NSByteOrder.h"
#import "Foundation/NSCharacterSet.h"
#import "Foundation/NSData.h"
#import "Foundation/NSDictionary.h"
#import "Foundation/NSError.h"
#import "Foundation/NSJSONSerialization.h"
#import "Foundation/NSNull.h"
#import "Foundation/NSStream.h"
#import "Foundation/NSString.h"
#import "Foundation/NSValue.h"
#import "GSFastEnumeration.h"
/* Boolean constants.
@ -897,15 +907,24 @@ writeObject(id obj, NSMutableString *output, NSInteger tabs)
@implementation NSJSONSerialization
+ (void) initialize
{
NSNullClass = [NSNull class];
NSArrayClass = [NSArray class];
NSStringClass = [NSString class];
NSDictionaryClass = [NSDictionary class];
NSNumberClass = [NSNumber class];
escapeSet = [NSMutableCharacterSet new];
[escapeSet addCharactersInString: @"\"\\"];
boolN = [[NSNumber alloc] initWithBool: NO];
boolY = [[NSNumber alloc] initWithBool: YES];
static BOOL beenHere = NO;
if (NO == beenHere)
{
NSNullClass = [NSNull class];
NSArrayClass = [NSArray class];
NSStringClass = [NSString class];
NSDictionaryClass = [NSDictionary class];
NSNumberClass = [NSNumber class];
escapeSet = [NSMutableCharacterSet new];
[[NSObject leakAt: &escapeSet] release];
[escapeSet addCharactersInString: @"\"\\"];
boolN = [[NSNumber alloc] initWithBool: NO];
[[NSObject leakAt: &boolN] release];
boolY = [[NSNumber alloc] initWithBool: YES];
[[NSObject leakAt: &boolY] release];
beenHere = YES;
}
}
+ (NSData*) dataWithJSONObject: (id)obj

View file

@ -41,7 +41,6 @@
#import "GNUstepBase/GSObjCRuntime.h"
#import "GNUstepBase/Unicode.h"
#import "GNUstepBase/GSLock.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GSInvocation.h"
#if defined(USE_LIBFFI)

View file

@ -30,7 +30,6 @@
#import "Foundation/NSException.h"
#import "Foundation/NSScanner.h"
#import "Foundation/NSValue.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GSPrivate.h"
@ -505,6 +504,7 @@ static NSDictionary *makeReference(unsigned ref)
globalClassMap =
NSCreateMapTable(NSNonOwnedPointerMapKeyCallBacks,
NSObjectMapValueCallBacks, 0);
[[NSObject leakAt: &globalClassMap] release];
}
}

View file

@ -313,6 +313,7 @@ static NSMapTable *globalClassMap = 0;
globalClassMap =
NSCreateMapTable(NSObjectMapKeyCallBacks,
NSNonOwnedPointerMapValueCallBacks, 0);
[[NSObject leakAt: &globalClassMap] release];
}
}

View file

@ -185,7 +185,9 @@ static NSRecursiveLock *classLock = nil;
if (self == [NSLocale class])
{
classLock = [GSLazyRecursiveLock new];
[[NSObject leakAt: &classLock] release];
allLocales = [[NSMutableDictionary alloc] initWithCapacity: 0];
[[NSObject leakAt: &allLocales] release];
}
}

View file

@ -24,7 +24,6 @@
#import "common.h"
#include <pthread.h>
#import "GNUstepBase/GSConfig.h"
#import "GSPrivate.h"
#define gs_cond_t pthread_cond_t
#define gs_mutex_t pthread_mutex_t

View file

@ -31,7 +31,6 @@
#import "Foundation/NSPointerFunctions.h"
#import "Foundation/NSMapTable.h"
#import "NSCallBacks.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
@interface NSConcreteMapTable : NSMapTable
@end

View file

@ -27,6 +27,7 @@
#define EXPOSE_NSMessagePort_IVARS 1
#import "GNUstepBase/GSLock.h"
#import "Foundation/NSArray.h"
#import "Foundation/NSAutoreleasePool.h"
#import "Foundation/NSNotification.h"
#import "Foundation/NSException.h"
#import "Foundation/NSRunLoop.h"
@ -37,7 +38,6 @@
#import "Foundation/NSPortMessage.h"
#import "Foundation/NSPortNameServer.h"
#import "Foundation/NSLock.h"
#import "Foundation/NSThread.h"
#import "Foundation/NSConnection.h"
#import "Foundation/NSPathUtilities.h"
#import "Foundation/NSValue.h"
@ -1099,12 +1099,11 @@ static NSMapTable *messagePortMap = 0;
static Class messagePortClass;
static void clean_up_sockets(void)
+ (void) atExit
{
NSMessagePort *port;
NSData *name;
NSMapEnumerator mEnum;
BOOL unknownThread = GSRegisterCurrentThread();
NSAutoreleasePool *arp = [NSAutoreleasePool new];
mEnum = NSEnumerateMapTable(messagePortMap);
@ -1114,11 +1113,9 @@ static void clean_up_sockets(void)
unlink([name bytes]);
}
NSEndMapTableEnumeration(&mEnum);
DESTROY(messagePortMap);
DESTROY(messagePortLock);
[arp drain];
if (unknownThread == YES)
{
GSUnregisterCurrentThread();
}
}
typedef struct {
@ -1149,7 +1146,6 @@ typedef struct {
NSNonOwnedPointerMapValueCallBacks, 0);
messagePortLock = [GSLazyRecursiveLock new];
atexit(clean_up_sockets);
/* It's possible that an old process, with the same process ID as
* this one, got forcibly killed or crashed so that clean_up_sockets
@ -1189,6 +1185,7 @@ typedef struct {
}
}
[pool release];
[self registerAtExit];
}
}

View file

@ -95,12 +95,19 @@ static NSMapTable *portToNamesMap;
@end
static void clean_up_names(void)
/**
* Subclass of [NSPortNameServer] taking/returning instances of [NSMessagePort].
* Port removal functionality is not supported; if you want to cancel a service,
* you have to destroy the port (invalidate the [NSMessagePort] given to
* [NSPortNameServer-registerPort:forName:]).
*/
@implementation NSMessagePortNameServer
+ (void) atExit
{
NSMapEnumerator mEnum;
NSMessagePort *port;
NSString *name;
BOOL unknownThread = GSRegisterCurrentThread();
NSAutoreleasePool *arp = [NSAutoreleasePool new];
mEnum = NSEnumerateMapTable(portToNamesMap);
@ -109,21 +116,11 @@ static void clean_up_names(void)
[defaultServer removePort: port];
}
NSEndMapTableEnumeration(&mEnum);
DESTROY(portToNamesMap);
DESTROY(serverLock);
[arp drain];
if (unknownThread == YES)
{
GSUnregisterCurrentThread();
}
}
/**
* Subclass of [NSPortNameServer] taking/returning instances of [NSMessagePort].
* Port removal functionality is not supported; if you want to cancel a service,
* you have to destroy the port (invalidate the [NSMessagePort] given to
* [NSPortNameServer-registerPort:forName:]).
*/
@implementation NSMessagePortNameServer
+ (void) initialize
{
if (self == [NSMessagePortNameServer class])
@ -138,10 +135,10 @@ static void clean_up_names(void)
serverLock = [NSRecursiveLock new];
portToNamesMap = NSCreateMapTable(NSNonRetainedObjectMapKeyCallBacks,
NSObjectMapValueCallBacks, 0);
atexit(clean_up_names);
[self registerAtExit];
/* It's possible that an old process, with the same process ID as
* this one, got forcibly killed or crashed so that clean_up_names
* this one, got forcibly killed or crashed so that +atExit
* was never called.
* To deal with that unlikely situation, we need to remove all such
* names which have been left over.

View file

@ -24,6 +24,8 @@
AutogsdocSource: NSMetadata.m
*/
#import "common.h"
#define EXPOSE_NSMetadataItem_IVARS 1
#define EXPOSE_NSMetadataQuery_IVARS 1
#define EXPOSE_NSMetadataQueryAttributeValueTuple_IVARS 1
@ -36,7 +38,6 @@
#import "Foundation/NSPredicate.h"
#import "Foundation/NSString.h"
#import "Foundation/NSTimer.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
// Metadata item constants...
NSString * const NSMetadataItemFSNameKey = @"NSMetadataItemFSNameKey";

View file

@ -24,10 +24,9 @@
Boston, MA 02111 USA.
*/
#import "common.h"
#import "GSNetServices.h"
#import "GSFastEnumeration.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GNUstepBase/GSConfig.h"
#import "GNUstepBase/NSNetServices+GNUstepBase.h"
#import "Foundation/NSArray.h"
#import "Foundation/NSData.h"

View file

@ -30,7 +30,6 @@
#import "Foundation/NSNotification.h"
#import "Foundation/NSCoder.h"
#import "Foundation/NSDictionary.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
@class GSNotification;
@interface GSNotification : NSObject // Help the compiler

View file

@ -37,7 +37,6 @@
#import "Foundation/NSLock.h"
#import "Foundation/NSThread.h"
#import "GNUstepBase/GSLock.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
static NSZone *_zone = 0;

View file

@ -285,6 +285,7 @@ static NSArray *defaultMode = nil;
{
defaultMode = [[NSArray alloc] initWithObjects: (id*)&NSDefaultRunLoopMode
count: 1];
[[NSObject leakAt: &defaultMode] release];
}
}

View file

@ -50,6 +50,7 @@ static NSNull *null = 0;
if (null == 0)
{
null = (NSNull*)NSAllocateObject(self, 0, NSDefaultMallocZone());
[[NSObject leakAt: &null] release];
}
}

View file

@ -42,11 +42,11 @@
#endif
#import "common.h"
#import "Foundation/NSCoder.h"
#import "Foundation/NSDecimalNumber.h"
#import "Foundation/NSException.h"
#import "Foundation/NSValue.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#if __has_include(<objc/runtime.h>)
# include <objc/runtime.h>
#endif
@ -653,9 +653,11 @@ static NSBoolNumber *boolN; // Boolean NO (integer 0)
NSDoubleNumberClass = [NSDoubleNumber class];
boolY = NSAllocateObject (NSBoolNumberClass, 0, 0);
[[NSObject leakAt: &boolY] release];
boolY->value = 1;
boolN = NSAllocateObject (NSBoolNumberClass, 0, 0);
boolN->value = 0;
[[NSObject leakAt: &boolN] release];
for (i = 0; i < 14; i++)
{
@ -663,6 +665,7 @@ static NSBoolNumber *boolN; // Boolean NO (integer 0)
n->value = i - 1;
ReusedInstances[i] = n;
[[NSObject leakAt: &ReusedInstances[i]] release];
}
}

View file

@ -27,7 +27,6 @@
#import "common.h"
#import "Foundation/NSArray.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
@implementation NSObject (NSComparisonMethods)
- (BOOL) doesContain: (id) object

View file

@ -47,7 +47,6 @@
#import "Foundation/NSNotification.h"
#import "Foundation/NSMapTable.h"
#import "GNUstepBase/GSLocale.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif

View file

@ -92,6 +92,7 @@ static NSArray *empty = nil;
+ (void) initialize
{
empty = [NSArray new];
[[NSObject leakAt: &empty] release];
}
- (void) addDependency: (NSOperation *)op
@ -878,6 +879,7 @@ static NSOperationQueue *mainQueue = nil;
if (mainQueue == nil)
{
mainQueue = [self new];
[[NSObject leakAt: &mainQueue] release];
[[[NSThread currentThread] threadDictionary] setObject: mainQueue
forKey: threadKey];
}

View file

@ -223,6 +223,9 @@ static BOOL ParseConfigurationFile(NSString *name, NSMutableDictionary *dict,
static void InitialisePathUtilities(void);
static void ShutdownPathUtilities(void);
@interface GSPathUtilities : NSObject
@end
/* Conditionally assign an object from a dictionary to var
* We don't need to retain val before releasing var, because we
* can be sure that if var is val it is retained by the dictionary
@ -894,10 +897,16 @@ NSMutableDictionary*
GNUstepConfig(NSDictionary *newConfig)
{
static NSDictionary *config = nil;
static BOOL beenHere = NO;
NSMutableDictionary *conf = nil;
BOOL changedSystemConfig = NO;
[gnustep_global_lock lock];
if (NO == beenHere)
{
beenHere = YES;
[[NSObject leakAt: &config] release];
}
if (config == nil || (newConfig != nil && [config isEqual: newConfig] == NO))
{
NS_DURING
@ -1124,8 +1133,18 @@ static void InitialisePathUtilities(void)
NS_DURING
{
NSMutableDictionary *config;
static BOOL beenHere = NO;
[gnustep_global_lock lock];
if (NO == beenHere)
{
beenHere = YES;
if (YES == [NSObject shouldCleanUp])
{
// Get path utilities shutdown called at process exit.
[GSPathUtilities class];
}
}
ASSIGNCOPY(uninstalled, [[[NSProcessInfo processInfo] environment]
objectForKey: @"GNUSTEP_UNINSTALLED_LIBRARY_DIRECTORY"]);
gnustepUserName = [NSUserName() copy];
@ -2470,3 +2489,14 @@ if (domainMask & mask) \
return paths;
}
@implementation GSPathUtilities
+ (void) atExit
{
ShutdownPathUtilities();
}
+ (void) initialize
{
[self registerAtExit];
}
@end

View file

@ -31,7 +31,6 @@
#import "Foundation/NSException.h"
#import "Foundation/NSValue.h"
#import "Foundation/NSKeyedArchiver.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GSPrivate.h"
#import "NSConcretePointerFunctions.h"

View file

@ -25,7 +25,6 @@
#import "common.h"
#import "NSConcretePointerFunctions.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
static Class abstractClass = Nil;
static Class concreteClass = Nil;

View file

@ -37,7 +37,6 @@
#import "Foundation/NSAutoreleasePool.h"
#import "Foundation/NSUserDefaults.h"
#import "GSPrivate.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
@class NSMessagePort;

View file

@ -31,7 +31,6 @@
#import "Foundation/NSData.h"
#import "Foundation/NSException.h"
#import "Foundation/NSPortMessage.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
@implementation NSPortMessage

View file

@ -33,7 +33,6 @@
#import "Foundation/NSLock.h"
#import "Foundation/NSUserDefaults.h"
#import "GSPortPrivate.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
/**

View file

@ -47,7 +47,6 @@
#import "Foundation/NSValue.h"
#import "GSPrivate.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
// For pow()
#include <math.h>

View file

@ -108,7 +108,6 @@
#include <crt_externs.h>
#endif
#import "GNUstepBase/GSConfig.h"
#import "Foundation/NSArray.h"
#import "Foundation/NSSet.h"
#import "Foundation/NSCharacterSet.h"

View file

@ -46,7 +46,6 @@
#import "Foundation/NSXMLParser.h"
#import "GNUstepBase/Unicode.h"
#import "GNUstepBase/NSProcessInfo+GNUstepBase.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GNUstepBase/NSString+GNUstepBase.h"
#import "GSPrivate.h"
@ -54,13 +53,6 @@
static id boolN = nil;
static id boolY = nil;
static void
setupBooleans()
{
if (nil == boolN) boolN = [[NSNumber numberWithBool: NO] retain];
if (nil == boolY) boolY = [[NSNumber numberWithBool: YES] retain];
}
@class GSSloppyXMLParser;
#define inrange(ch,min,max) ((ch)>=(min) && (ch)<=(max))
@ -589,33 +581,6 @@ static const unsigned char whitespace[32] = {
static NSCharacterSet *oldQuotables = nil;
static NSCharacterSet *xmlQuotables = nil;
static void setupQuotables(void)
{
if (nil == oldQuotables)
{
NSMutableCharacterSet *s;
/* The '$', '.', '/' and '_' characters used to be OK to use in
* property lists, but OSX now quotes them, so we follow suite.
*/
s = [NSMutableCharacterSet new];
[s addCharactersInString:
@"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
@"abcdefghijklmnopqrstuvwxyz"];
[s invert];
oldQuotables = s;
s = [NSMutableCharacterSet new];
[s addCharactersInString: @"&<>'\\\""];
[s addCharactersInRange: NSMakeRange(0x0001, 0x001f)];
[s removeCharactersInRange: NSMakeRange(0x0009, 0x0002)];
[s removeCharactersInRange: NSMakeRange(0x000D, 0x0001)];
[s addCharactersInRange: NSMakeRange(0xD800, 0x07FF)];
[s addCharactersInRange: NSMakeRange(0xFFFE, 0x0002)];
xmlQuotables = s;
}
}
typedef struct {
const unsigned char *ptr;
unsigned end;
@ -2335,6 +2300,8 @@ static BOOL classInitialized = NO;
{
if (classInitialized == NO)
{
NSMutableCharacterSet *s;
classInitialized = YES;
NSStringClass = [NSString class];
@ -2355,8 +2322,32 @@ static BOOL classInitialized = NO;
plSet = (id (*)(id, SEL, id, id))
[plDictionary instanceMethodForSelector: @selector(setObject:forKey:)];
setupQuotables();
setupBooleans();
/* The '$', '.', '/' and '_' characters used to be OK to use in
* property lists, but OSX now quotes them, so we follow suite.
*/
s = [NSMutableCharacterSet new];
[s addCharactersInString:
@"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
@"abcdefghijklmnopqrstuvwxyz"];
[s invert];
oldQuotables = s;
[[NSObject leakAt: &oldQuotables] release];
s = [NSMutableCharacterSet new];
[s addCharactersInString: @"&<>'\\\""];
[s addCharactersInRange: NSMakeRange(0x0001, 0x001f)];
[s removeCharactersInRange: NSMakeRange(0x0009, 0x0002)];
[s removeCharactersInRange: NSMakeRange(0x000D, 0x0001)];
[s addCharactersInRange: NSMakeRange(0xD800, 0x07FF)];
[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];
}
}

View file

@ -706,6 +706,7 @@ static inline BOOL timerInvalidated(NSTimer *t)
{
[self currentRunLoop];
theFuture = RETAIN([NSDate distantFuture]);
[[NSObject leakAt: &theFuture] release];
}
}

View file

@ -51,7 +51,6 @@
#import "Foundation/NSScanner.h"
#import "Foundation/NSException.h"
#import "Foundation/NSUserDefaults.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GSPrivate.h"

View file

@ -38,7 +38,6 @@
#import "Foundation/NSNotification.h"
#import "Foundation/NSNotificationQueue.h"
#import "Foundation/NSValue.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GSPrivate.h"

View file

@ -37,7 +37,6 @@
// For private method _decodeArrayOfObjectsForKey:
#import "Foundation/NSKeyedArchiver.h"
#import "GSPrivate.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GSFastEnumeration.h"
#import "GSDispatch.h"

View file

@ -1494,9 +1494,10 @@ static Class tcpPortClass;
{
tcpPortClass = self;
tcpPortMap = NSCreateMapTable(NSIntegerMapKeyCallBacks,
NSNonOwnedPointerMapValueCallBacks, 0);
NSObjectMapValueCallBacks, 0);
[[NSObject leakAt: &tcpPortMap] release];
tcpPortLock = [GSLazyRecursiveLock new];
[[NSObject leakAt: &tcpPortLock] release];
}
}
@ -1706,6 +1707,7 @@ static Class tcpPortClass;
NSNonOwnedPointerMapValueCallBacks, 0);
NSMapInsert(tcpPortMap, (void*)(uintptr_t)port->portNum,
(void*)thePorts);
RELEASE(thePorts);
}
/*
* Ok - now add the port for the host
@ -1732,6 +1734,7 @@ static Class tcpPortClass;
NSNonOwnedPointerMapValueCallBacks, 0);
NSMapInsert(tcpPortMap,
(void*)(uintptr_t)number, (void*)thePorts);
RELEASE(thePorts);
}
/*
* Record the port by host.

View file

@ -561,10 +561,13 @@ typedef enum {
if (self == [NSSocketPortNameServer class])
{
serverLock = [NSRecursiveLock new];
[[NSObject leakAt: &serverLock] release];
modes = [[NSArray alloc] initWithObjects: &mode count: 1];
[[NSObject leakAt: &modes] release];
#ifdef GDOMAP_PORT_OVERRIDE
serverPort = RETAIN([NSString stringWithUTF8String:
make_gdomap_port(GDOMAP_PORT_OVERRIDE)]);
[[NSObject leakAt: &serverPort] release];
#endif
portClass = [NSSocketPort class];
}

View file

@ -32,7 +32,6 @@
#import "Foundation/NSKeyValueCoding.h"
#import "GNUstepBase/GSObjCRuntime.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GSPrivate.h"
#import "GSSorting.h"

View file

@ -74,7 +74,6 @@
#import "GNUstepBase/GSMime.h"
#import "GNUstepBase/NSString+GNUstepBase.h"
#import "GNUstepBase/NSMutableString+GNUstepBase.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GSPrivate.h"
#include <sys/stat.h>
#include <sys/types.h>
@ -271,7 +270,7 @@ pathSeps(void)
{
rPathSeps
= [NSCharacterSet characterSetWithCharactersInString: @"/\\"];
IF_NO_GC(RETAIN(rPathSeps));
rPathSeps = [NSObject leakAt: &rPathSeps];
}
[placeholderLock unlock];
}
@ -286,7 +285,7 @@ pathSeps(void)
{
uPathSeps
= [NSCharacterSet characterSetWithCharactersInString: @"/"];
IF_NO_GC(RETAIN(uPathSeps));
uPathSeps = [NSObject leakAt: &uPathSeps];
}
[placeholderLock unlock];
}
@ -301,7 +300,7 @@ pathSeps(void)
{
wPathSeps
= [NSCharacterSet characterSetWithCharactersInString: @"\\"];
IF_NO_GC(RETAIN(wPathSeps));
wPathSeps = [NSObject leakAt: &wPathSeps];
}
[placeholderLock unlock];
}

View file

@ -45,7 +45,6 @@
#import "Foundation/NSTimer.h"
#import "Foundation/NSLock.h"
#import "GNUstepBase/NSString+GNUstepBase.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GSPrivate.h"
#include <sys/types.h>
@ -259,6 +258,7 @@ pty_slave(const char* name)
if (tasksLock == nil)
{
tasksLock = [NSRecursiveLock new];
[[NSObject leakAt: &tasksLock] release];
/* The activeTasks map contains the NSTask objects corresponding
* to running subtasks, and retains them until the subprocess
* actually terminates.
@ -283,6 +283,7 @@ pty_slave(const char* name)
*/
activeTasks = NSCreateMapTable(NSIntegerMapKeyCallBacks,
NSObjectMapValueCallBacks, 0);
[[NSObject leakAt: &activeTasks] release];
}
[gnustep_global_lock unlock];

View file

@ -18,10 +18,10 @@
Boston, MA 02111 USA.
*/
#import "common.h"
#import "Foundation/NSException.h"
#import "Foundation/NSTextCheckingResult.h"
#import "Foundation/NSRegularExpression.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
/**
* Private class encapsulating a regular expression match.

View file

@ -106,8 +106,6 @@
#import "Foundation/NSTimeZone.h"
#import "Foundation/NSByteOrder.h"
#import "Foundation/NSLocale.h"
#import "GNUstepBase/GSConfig.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GNUstepBase/NSString+GNUstepBase.h"
#import "GSPrivate.h"

View file

@ -623,6 +623,7 @@ static NSUInteger urlAlign;
{
NSGetSizeAndAlignment(@encode(parsedURL), &urlAlign, 0);
clientsLock = [NSLock new];
[[NSObject leakAt: &clientsLock] release];
}
}

View file

@ -26,7 +26,6 @@
#define EXPOSE_NSURLCache_IVARS 1
#import "GSURLPrivate.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
// FIXME ... locking and disk storage needed
typedef struct {

View file

@ -35,7 +35,6 @@
#import "Foundation/NSURLHandle.h"
#import "Foundation/NSRunLoop.h"
#import "Foundation/NSFileManager.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
@class GSFTPURLHandle;
@ -177,7 +176,9 @@ static Class NSURLHandleClass = 0;
{
NSURLHandleClass = self;
registry = [NSMutableArray new];
[[NSObject leakAt: &registry] release];
registryLock = [NSLock new];
[[NSObject leakAt: &registryLock] release];
[self registerURLHandleClass: [GSFileURLHandle class]];
[self registerURLHandleClass: [GSFTPURLHandle class]];
[self registerURLHandleClass: [GSHTTPURLHandle class]];
@ -675,7 +676,9 @@ static NSLock *fileLock = nil;
+ (void) initialize
{
fileCache = [NSMutableDictionary new];
[[NSObject leakAt: &fileCache] release];
fileLock = [NSLock new];
[[NSObject leakAt: &fileLock] release];
}
- (NSData*) availableResourceData

View file

@ -36,7 +36,6 @@
#import "GSTLS.h"
#import "GSURLPrivate.h"
#import "GNUstepBase/GSMime.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GNUstepBase/NSString+GNUstepBase.h"
#import "GNUstepBase/NSURL+GNUstepBase.h"
@ -98,7 +97,9 @@ static NSLock *pairLock = nil;
* to the same value.
*/
pairCache = [NSMutableArray new];
[[NSObject leakAt: &pairCache] release];
pairLock = [NSLock new];
[[NSObject leakAt: &pairLock] release];
/* Purge expired pairs at intervals.
*/
[[NSNotificationCenter defaultCenter] addObserver: self
@ -366,8 +367,11 @@ static NSURLProtocol *placeholder = nil;
placeholderClass = [NSURLProtocolPlaceholder class];
placeholder = (NSURLProtocol*)NSAllocateObject(placeholderClass, 0,
NSDefaultMallocZone());
[[NSObject leakAt: &placeholder] release];
registered = [NSMutableArray new];
[[NSObject leakAt: &registered] release];
regLock = [NSLock new];
[[NSObject leakAt: &regLock] release];
[self registerClass: [_NSHTTPURLProtocol class]];
[self registerClass: [_NSHTTPSURLProtocol class]];
[self registerClass: [_NSFTPURLProtocol class]];

View file

@ -54,7 +54,6 @@
#import "GNUstepBase/GSLocale.h"
#import "GNUstepBase/GSLock.h"
#import "GNUstepBase/NSProcessInfo+GNUstepBase.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GNUstepBase/NSString+GNUstepBase.h"
#if defined(__MINGW__)
@ -543,11 +542,9 @@ newLanguages(NSArray *oldNames)
+ (void) atExit
{
id tmp;
tmp = sharedDefaults;
sharedDefaults = nil;
[tmp release];
DESTROY(sharedDefaults);
DESTROY(processName);
DESTROY(classLock);
}
+ (void) initialize

View file

@ -35,7 +35,6 @@
#import "Foundation/NSMapTable.h"
#import "Foundation/NSLock.h"
#import "Foundation/NSData.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
@interface GSPlaceholderValue : NSValue
@end

View file

@ -32,7 +32,6 @@
#import "Foundation/NSArchiver.h"
#import "Foundation/NSValue.h"
#import "Foundation/NSValueTransformer.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GNUstepBase/GSLock.h"
@interface NSNegateBooleanTransformer : NSValueTransformer
@ -62,7 +61,9 @@ static GSLazyLock *lock = nil;
NSValueTransformer *t;
lock = [GSLazyLock new];
[[NSObject leakAt: &lock] release];
registry = [[NSMutableDictionary alloc] init];
[[NSObject leakAt: &registry] release];
t = [NSNegateBooleanTransformer new];
[self setValueTransformer: t

View file

@ -35,7 +35,6 @@
#import "Foundation/NSData.h"
#import "Foundation/NSDictionary.h"
#import "Foundation/NSNull.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GNUstepBase/GSMime.h"
@interface GSMimeDocument (internal)
@ -441,6 +440,7 @@ static NSNull *null = nil;
if (null == nil)
{
null = RETAIN([NSNull null]);
[[NSObject leakAt: &null] release];
}
}
@ -676,6 +676,7 @@ static SEL foundIgnorableSel;
if (null == nil)
{
null = RETAIN([NSNull null]);
[[NSObject leakAt: &null] release];
}
if (didEndElementSel == 0)
{

View file

@ -202,7 +202,6 @@ StringFromXMLString(const unsigned char *bytes, unsigned length)
#import "Foundation/NSXMLDTDNode.h"
#import "Foundation/NSXMLDTD.h"
#import "Foundation/NSXMLElement.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#ifdef HAVE_LIBXML

View file

@ -49,6 +49,7 @@
* "Foundation/NSObject.h" first, to ensure we have a local copy.
*/
#import "Foundation/NSObject.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
/* These headers are used in almost every file.
*/

View file

@ -26,7 +26,6 @@
#import "Foundation/NSArray.h"
#import "Foundation/NSException.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GSPrivate.h"

Some files were not shown because too many files have changed in this diff Show more