Fix for strict OPENSTEP

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@6863 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 2000-07-03 13:18:07 +00:00
parent 7617609b41
commit a8432b33bc
2 changed files with 46 additions and 45 deletions

View file

@ -10,9 +10,10 @@
* Source/NSPort.m: Create GSTcpPort by default. * Source/NSPort.m: Create GSTcpPort by default.
* Source/externs.m: GSBuildStrings() now used to make string * Source/externs.m: GSBuildStrings() now used to make string
constants that support cached hash values constants that support cached hash values
* Tools/client.m: Added simple benchmarking. * Testing/client.m: Added simple benchmarking.
* Tools/server.m: Added method for simple benchmarking. * Testing/server.m: Added method for simple benchmarking.
* Tools/server.h: Added method for simple benchmarking. * Testing/server.h: Added method for simple benchmarking.
* Tools/gdnc.m: String OPENSTEP use of DO
2000-07-02 Richard Frith-Macdonald <rfm@gnu.org> 2000-07-02 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -51,9 +51,9 @@
@implementation GDNCNotification @implementation GDNCNotification
- (void) dealloc - (void) dealloc
{ {
[name release]; RELEASE(name);
[object release]; RELEASE(object);
[info release]; RELEASE(info);
[super dealloc]; [super dealloc];
} }
+ (GDNCNotification*) notificationWithName: (NSString*)notificationName + (GDNCNotification*) notificationWithName: (NSString*)notificationName
@ -62,10 +62,10 @@
{ {
GDNCNotification *tmp = [GDNCNotification alloc]; GDNCNotification *tmp = [GDNCNotification alloc];
tmp->name = [notificationName retain]; tmp->name = RETAIN(notificationName);
tmp->object = [notificationObject retain]; tmp->object = RETAIN(notificationObject);
tmp->info = [notificationData retain]; tmp->info = RETAIN(notificationData);
return [tmp autorelease]; return AUTORELEASE(tmp);
} }
@end @end
@ -85,7 +85,7 @@
@implementation GDNCClient @implementation GDNCClient
- (void) dealloc - (void) dealloc
{ {
[observers release]; RELEASE(observers);
[super dealloc]; [super dealloc];
} }
@ -118,10 +118,10 @@
- (void) dealloc - (void) dealloc
{ {
[queue release]; RELEASE(queue);
[selector release]; RELEASE(selector);
[notificationName release]; RELEASE(notificationName);
[notificationObject release]; RELEASE(notificationObject);
[super dealloc]; [super dealloc];
} }
@ -149,8 +149,8 @@
suspensionBehavior: (NSNotificationSuspensionBehavior)suspensionBehavior suspensionBehavior: (NSNotificationSuspensionBehavior)suspensionBehavior
for: (id<GDNCClient>)client; for: (id<GDNCClient>)client;
- (NSConnection*) connection: (NSConnection*)ancestor - (BOOL) connection: (NSConnection*)ancestor
didConnect: (NSConnection*)newConn; shouldMakeNewConnection: (NSConnection*)newConn;
- (id) connectionBecameInvalid: (NSNotification*)notification; - (id) connectionBecameInvalid: (NSNotification*)notification;
@ -187,8 +187,7 @@
[nc removeObserver: self [nc removeObserver: self
name: NSConnectionDidDieNotification name: NSConnectionDidDieNotification
object: conn]; object: conn];
[conn release]; DESTROY(conn);
conn = nil;
} }
/* /*
@ -215,8 +214,8 @@
/* /*
* And release the maps of notification names and objects. * And release the maps of notification names and objects.
*/ */
[observersForNames release]; RELEASE(observersForNames);
[observersForObjects release]; RELEASE(observersForObjects);
[super dealloc]; [super dealloc];
} }
@ -227,13 +226,13 @@
allObservers = NSCreateHashTable(NSNonOwnedPointerHashCallBacks, 0); allObservers = NSCreateHashTable(NSNonOwnedPointerHashCallBacks, 0);
observersForNames = [NSMutableDictionary new]; observersForNames = [NSMutableDictionary new];
observersForObjects = [NSMutableDictionary new]; observersForObjects = [NSMutableDictionary new];
conn = [NSConnection newRegisteringAtName: GDNC_SERVICE conn = [NSConnection defaultConnection];
withRootObject: self]; [conn setRootObject: self];
if (conn == nil) if ([conn registerName: GDNC_SERVICE] == NO)
{ {
NSLog(@"gdnc - unable to register with name server - quiting.\n"); NSLog(@"gdnc - unable to register with name server - quiting.\n");
[self release]; DESTROY(self);
return nil; return self;
} }
/* /*
@ -284,7 +283,7 @@
obs->behavior = suspensionBehavior; obs->behavior = suspensionBehavior;
obs->selector = [aSelector copy]; obs->selector = [aSelector copy];
[info->observers addObject: obs]; [info->observers addObject: obs];
[obs release]; RELEASE(obs);
NSHashInsert(allObservers, obs); NSHashInsert(allObservers, obs);
/* /*
@ -300,7 +299,7 @@
{ {
objList = [NSMutableArray new]; objList = [NSMutableArray new];
[observersForObjects setObject: objList forKey: anObject]; [observersForObjects setObject: objList forKey: anObject];
[objList release]; RELEASE(objList);
} }
/* /*
* If possible use an existing string as the key. * If possible use an existing string as the key.
@ -311,7 +310,7 @@
anObject = tmp->notificationObject; anObject = tmp->notificationObject;
} }
obs->notificationObject = [anObject retain]; obs->notificationObject = RETAIN(anObject);
[objList addObject: obs]; [objList addObject: obs];
} }
@ -324,7 +323,7 @@
{ {
namList = [NSMutableArray new]; namList = [NSMutableArray new];
[observersForNames setObject: namList forKey: notificationName]; [observersForNames setObject: namList forKey: notificationName];
[namList release]; RELEASE(namList);
} }
/* /*
* If possible use an existing string as the key. * If possible use an existing string as the key.
@ -335,14 +334,14 @@
notificationName = tmp->notificationObject; notificationName = tmp->notificationObject;
} }
obs->notificationName = [notificationName retain]; obs->notificationName = RETAIN(notificationName);
[namList addObject: obs]; [namList addObject: obs];
} }
} }
- (NSConnection*) connection: (NSConnection*)ancestor - (BOOL) connection: (NSConnection*)ancestor
didConnect: (NSConnection*)newConn shouldMakeNewConnection: (NSConnection*)newConn;
{ {
NSMapTable *table; NSMapTable *table;
@ -360,7 +359,7 @@
table = NSCreateMapTable(NSObjectMapKeyCallBacks, table = NSCreateMapTable(NSObjectMapKeyCallBacks,
NSObjectMapValueCallBacks, 0); NSObjectMapValueCallBacks, 0);
NSMapInsert(connections, newConn, table); NSMapInsert(connections, newConn, table);
return newConn; return YES;
} }
- (id) connectionBecameInvalid: (NSNotification*)notification - (id) connectionBecameInvalid: (NSNotification*)notification
@ -415,7 +414,7 @@
info = [GDNCClient new]; info = [GDNCClient new];
info->client = client; info->client = client;
NSMapInsert(table, client, info); NSMapInsert(table, client, info);
[info release]; RELEASE(info);
} }
- (void) postNotificationName: (NSString*)notificationName - (void) postNotificationName: (NSString*)notificationName
@ -524,19 +523,18 @@
{ {
GDNCNotification *n; GDNCNotification *n;
n = [[obs->queue objectAtIndex: 0] retain]; n = RETAIN([obs->queue objectAtIndex: 0]);
[obs->queue removeObjectAtIndex: 0]; [obs->queue removeObjectAtIndex: 0];
[obs->client->client postNotificationName: n->name [obs->client->client postNotificationName: n->name
object: n->object object: n->object
userInfo: n->info userInfo: n->info
selector: obs->selector selector: obs->selector
to: obs->observer]; to: obs->observer];
[n release]; RELEASE(n);
} }
NS_HANDLER NS_HANDLER
{ {
[obs release]; DESTROY(obs);
obs = nil;
} }
NS_ENDHANDLER NS_ENDHANDLER
} }
@ -753,20 +751,19 @@ int
main(int argc, char** argv, char** env) main(int argc, char** argv, char** env)
{ {
GDNCServer *server; GDNCServer *server;
NSAutoreleasePool *pool;
NSString *str; NSString *str;
BOOL shouldFork = YES; BOOL shouldFork = YES;
CREATE_AUTORELEASE_POOL(pool);
#ifdef GS_PASS_ARGUMENTS #ifdef GS_PASS_ARGUMENTS
[NSProcessInfo initializeWithArguments:argv count:argc environment:env]; [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
#endif #endif
pool = [NSAutoreleasePool new];
str = [[NSUserDefaults standardUserDefaults] stringForKey: @"debug"]; str = [[NSUserDefaults standardUserDefaults] stringForKey: @"debug"];
if (str != nil && [str caseInsensitiveCompare: @"yes"] == NSOrderedSame) if (str != nil && [str caseInsensitiveCompare: @"yes"] == NSOrderedSame)
{ {
shouldFork = NO; shouldFork = NO;
} }
[pool release]; RELEASE(pool);
if (shouldFork) if (shouldFork)
{ {
@ -792,9 +789,12 @@ main(int argc, char** argv, char** env)
} }
} }
pool = [NSAutoreleasePool new]; {
CREATE_AUTORELEASE_POOL(pool);
server = [GDNCServer new]; server = [GDNCServer new];
[pool release]; RELEASE(pool);
}
if (server != nil) if (server != nil)
{ {
[[NSRunLoop currentRunLoop] run]; [[NSRunLoop currentRunLoop] run];