From 629389a62bd68e102fbba8481850545bc5d93326 Mon Sep 17 00:00:00 2001 From: Dave Wetzel Date: Thu, 22 Apr 2010 07:57:58 +0000 Subject: [PATCH] GSWApplication.*: * use [[NSThread currentThread] threadDictionary] GSWMultiKeyDictionary.m * fix format GSWRequest.m * fix potential double release GSWComponentRequestHandler.* * add comments for rejectFavicon GSWSessionTimeOutManager.m * fix index NSString+HTML.m, GSWBaseParser.m, GSWDeclarationParser.m, GSWHTMLRawParser.m * use NSZoneMalloc() git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@30216 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 14 ++++++++++++ GSWeb.framework/GSWApplication.h | 1 - GSWeb.framework/GSWApplication.m | 24 ++++++++------------ GSWeb.framework/GSWBaseParser.m | 3 +-- GSWeb.framework/GSWComponentRequestHandler.h | 1 + GSWeb.framework/GSWComponentRequestHandler.m | 5 ++++ GSWeb.framework/GSWDeclarationParser.m | 7 ++---- GSWeb.framework/GSWHTMLRawParser.m | 5 ++-- GSWeb.framework/GSWMultiKeyDictionary.m | 2 +- GSWeb.framework/GSWRequest.m | 1 - GSWeb.framework/GSWSessionTimeOutManager.m | 9 +++----- GSWeb.framework/GSWUtils.m | 2 +- GSWeb.framework/NSString+HTML.m | 5 ++-- 13 files changed, 43 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index d97b337..f9cb9e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2010-04-16 David Wetzel + GSWApplication.*: + * use [[NSThread currentThread] threadDictionary] + GSWMultiKeyDictionary.m + * fix format + GSWRequest.m + * fix potential double release + GSWComponentRequestHandler.* + * add comments for rejectFavicon + GSWSessionTimeOutManager.m + * fix index + NSString+HTML.m, GSWBaseParser.m, GSWDeclarationParser.m, GSWHTMLRawParser.m + * use NSZoneMalloc() + 2010-04-16 David Wetzel * fixed memory leak * ported to OS X (beta) diff --git a/GSWeb.framework/GSWApplication.h b/GSWeb.framework/GSWApplication.h index e228b2a..5fc15d5 100644 --- a/GSWeb.framework/GSWApplication.h +++ b/GSWeb.framework/GSWApplication.h @@ -91,7 +91,6 @@ GSWEB_EXPORT BOOL WOStrictFlag; NSMutableDictionary* _requestHandlers; GSWRequestHandler* _defaultRequestHandler; NSString* _hostAddress; - NSMutableDictionary* _contextDictionary; @public //TODO-NOW REMOVE NSRecursiveLock* _selfLock; #ifndef NDEBUG diff --git a/GSWeb.framework/GSWApplication.m b/GSWeb.framework/GSWApplication.m index b5a0a2f..6e20e98 100644 --- a/GSWeb.framework/GSWApplication.m +++ b/GSWeb.framework/GSWApplication.m @@ -298,7 +298,6 @@ int GSWApplicationMain(NSString* applicationClassName, [[self class] _setApplication:self]; [self _touchPrincipalClasses]; - _contextDictionary = [NSMutableDictionary new]; standardUserDefaults=[NSUserDefaults standardUserDefaults]; NSDebugMLLog(@"options",@"standardUserDefaults=%@",standardUserDefaults); @@ -412,7 +411,6 @@ int GSWApplicationMain(NSString* applicationClassName, DESTROY(_initialTimer); DESTROY(_activeSessionsCountLock); DESTROY(_lifebeatThread); - DESTROY(_contextDictionary); if (GSWApp == self) { @@ -1470,15 +1468,14 @@ int GSWApplicationMain(NSString* applicationClassName, //-------------------------------------------------------------------- -(void)_setContext:(GSWContext*)aContext { - SYNCHRONIZED(self) { - if (aContext) { - [_contextDictionary setObject:aContext - forKey:GSWThreadKey_Context]; - } else { - [_contextDictionary removeObjectForKey:GSWThreadKey_Context]; - } + NSMutableDictionary * thDict = [[NSThread currentThread] threadDictionary]; + + if (aContext) { + [thDict setObject:aContext + forKey:GSWThreadKey_Context]; + } else { + [thDict removeObjectForKey:GSWThreadKey_Context]; } - END_SYNCHRONIZED; } @@ -1488,10 +1485,9 @@ int GSWApplicationMain(NSString* applicationClassName, { GSWContext* context=nil; - SYNCHRONIZED(self) { - context=[_contextDictionary objectForKey:GSWThreadKey_Context]; - } - END_SYNCHRONIZED; + NSMutableDictionary * thDict = [[NSThread currentThread] threadDictionary]; + + context = [thDict objectForKey:GSWThreadKey_Context]; return context; } diff --git a/GSWeb.framework/GSWBaseParser.m b/GSWeb.framework/GSWBaseParser.m index 0d1e123..3963649 100644 --- a/GSWeb.framework/GSWBaseParser.m +++ b/GSWeb.framework/GSWBaseParser.m @@ -55,8 +55,7 @@ RCS_ID("$Id$") DESTROY(_string); if (_uniBuf) { - //objc_free(_uniBuf); - free(_uniBuf); + NSZoneFree(NSDefaultMallocZone(),_uniBuf); _uniBuf=NULL; }; [super dealloc]; diff --git a/GSWeb.framework/GSWComponentRequestHandler.h b/GSWeb.framework/GSWComponentRequestHandler.h index cebe7fa..cacb63f 100644 --- a/GSWeb.framework/GSWComponentRequestHandler.h +++ b/GSWeb.framework/GSWComponentRequestHandler.h @@ -39,6 +39,7 @@ /* returns YES. Subclassers might override this. + Used to reject requests to /favicon.ico in direct connect mode. */ - (BOOL) rejectFavicon; diff --git a/GSWeb.framework/GSWComponentRequestHandler.m b/GSWeb.framework/GSWComponentRequestHandler.m index 9b6c58c..9e4edc1 100644 --- a/GSWeb.framework/GSWComponentRequestHandler.m +++ b/GSWeb.framework/GSWComponentRequestHandler.m @@ -289,6 +289,11 @@ GSWResponse * _dispatchWithPreparedApplication(GSWApplication *app, GSWContext * return response; } +/* + returns YES. Subclassers might override this. + Used to reject requests to /favicon.ico in direct connect mode. + */ + - (BOOL) rejectFavicon { return YES; diff --git a/GSWeb.framework/GSWDeclarationParser.m b/GSWeb.framework/GSWDeclarationParser.m index e654af9..6419359 100644 --- a/GSWeb.framework/GSWDeclarationParser.m +++ b/GSWeb.framework/GSWDeclarationParser.m @@ -454,10 +454,8 @@ inline GSWDeclaration* parseDeclaration(GSWDeclarationParser* parser) { if (!_declarations) _declarations=(NSMutableDictionary*)[NSMutableDictionary new]; - // does not work on Snow Leopard. Any suggestions? -- dw - // _uniBuf = (unichar*)objc_malloc(sizeof(unichar)*(_length+1)); - _uniBuf = (unichar*)malloc(sizeof(unichar)*(_length+1)); + _uniBuf = (unichar*)NSZoneMalloc(NSDefaultMallocZone(),sizeof(unichar)*(_length+1)); NS_DURING { @@ -501,8 +499,7 @@ inline GSWDeclaration* parseDeclaration(GSWDeclarationParser* parser) { if (_uniBuf) { - //objc_free(_uniBuf); - free(_uniBuf); + NSZoneFree(NSDefaultMallocZone(),_uniBuf); _uniBuf=NULL; }; [localException raise]; diff --git a/GSWeb.framework/GSWHTMLRawParser.m b/GSWeb.framework/GSWHTMLRawParser.m index 4e1c889..45c988c 100644 --- a/GSWeb.framework/GSWHTMLRawParser.m +++ b/GSWeb.framework/GSWHTMLRawParser.m @@ -497,7 +497,7 @@ May raise exception. // does not work on Snow Leopard. Any suggestions? -- dw //_uniBuf = (unichar*)objc_malloc(sizeof(unichar)*(_length+1)); - _uniBuf = (unichar*)malloc(sizeof(unichar)*(_length+1)); + _uniBuf = (unichar*)NSZoneMalloc(NSDefaultMallocZone(),(sizeof(unichar)*(_length+1)); NS_DURING { @@ -637,8 +637,7 @@ May raise exception. { if (_uniBuf) { - //objc_free(_uniBuf); - free(_uniBuf); + NSZoneFree(NSDefaultMallocZone(),_uniBuf); _uniBuf=NULL; }; [localException raise]; diff --git a/GSWeb.framework/GSWMultiKeyDictionary.m b/GSWeb.framework/GSWMultiKeyDictionary.m index 1d04ebe..ff596d4 100644 --- a/GSWeb.framework/GSWMultiKeyDictionary.m +++ b/GSWeb.framework/GSWMultiKeyDictionary.m @@ -1094,7 +1094,7 @@ static void GSWMapBaseInitWithZoneAndCapacity(GSWMapBase base, { NSString* descr=nil; //TODO - descr=[NSString stringWithFormat:@"<%s %p>", + descr=[NSString stringWithFormat:@"<%s %@>", NSStringFromClass([self class]), (void*)self]; return descr; diff --git a/GSWeb.framework/GSWRequest.m b/GSWeb.framework/GSWRequest.m index 86ee082..c5dffb0 100644 --- a/GSWeb.framework/GSWRequest.m +++ b/GSWeb.framework/GSWRequest.m @@ -1520,7 +1520,6 @@ RCS_ID("$Id$") formValues=[self _extractValuesFromFormData:formData withEncoding:formValueEncoding]; - [_formValues release]; ASSIGN(_formValues,formValues); }; }; diff --git a/GSWeb.framework/GSWSessionTimeOutManager.m b/GSWeb.framework/GSWSessionTimeOutManager.m index da543c3..5f54c92 100644 --- a/GSWeb.framework/GSWSessionTimeOutManager.m +++ b/GSWeb.framework/GSWSessionTimeOutManager.m @@ -163,12 +163,9 @@ RCS_ID("$Id$") NSTimer* timer=nil; int removedNb=0; - NSUInteger timeOutCount = [_sessionOrderedTimeOuts count]; - NSUInteger index; - - index = timeOutCount-1; - - while ((index > 1) && ((sessionTimeOut = [_sessionOrderedTimeOuts objectAtIndex:index-1]))) + NSUInteger index = [_sessionOrderedTimeOuts count]; + + while ((index > 0) && ((sessionTimeOut = [_sessionOrderedTimeOuts objectAtIndex:index-1]))) { if ([sessionTimeOut timeOutTime]