Fixed coding/decoding autorelease problem.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2949 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1998-09-02 12:34:38 +00:00
parent bfd5967011
commit 13ba5809c0
8 changed files with 22 additions and 17 deletions

View file

@ -244,7 +244,7 @@ static BOOL debug_coder = NO;
references. */ references. */
id o; id o;
[self decodeObjectAt: &o withName: NULL]; [self decodeObjectAt: &o withName: NULL];
return o; return [o autorelease];
} }
- (unsigned int) systemVersion - (unsigned int) systemVersion

View file

@ -156,8 +156,8 @@ static id long_day[7] = {@"Sunday",
- (id) initWithCoder: (NSCoder*)aCoder - (id) initWithCoder: (NSCoder*)aCoder
{ {
self = [super initWithCoder: aCoder]; self = [super initWithCoder: aCoder];
calendar_format = [aCoder decodeObject]; [aCoder decodeValueOfObjCType: @encode(id) at: &calendar_format];
time_zone = [aCoder decodeObject]; [aCoder decodeValueOfObjCType: @encode(id) at: &time_zone];
return self; return self;
} }

View file

@ -147,9 +147,9 @@ _NSFoundationUncaughtExceptionHandler(NSException *exception)
- (id)initWithCoder: aDecoder - (id)initWithCoder: aDecoder
{ {
self = [super initWithCoder:aDecoder]; self = [super initWithCoder:aDecoder];
e_name = [[aDecoder decodeObject] retain]; [aDecoder decodeObjectAt: &e_name];
e_reason = [[aDecoder decodeObject] retain]; [aDecoder decodeObjectAt: &e_reason];
e_info = [[aDecoder decodeObject] retain]; [aDecoder decodeObjectAt: &e_info];
return self; return self;
} }

View file

@ -176,9 +176,9 @@ NSDictionary *_attributesAtIndexEffectiveRange(
- initWithCoder: aCoder - initWithCoder: aCoder
{ {
self = [super initWithCoder:aCoder]; self = [super initWithCoder:aCoder];
textChars = [[aCoder decodeObject] retain]; [aCoder decodeValueOfObjCType: @encode(id) at: &textChars];
attributeArray = [[aCoder decodeObject] retain]; [aCoder decodeValueOfObjCType: @encode(id) at: &attributeArray];
locateArray = [[aCoder decodeObject] retain]; [aCoder decodeValueOfObjCType: @encode(id) at: &locateArray];
return self; return self;
} }
@ -241,9 +241,9 @@ NSDictionary *_attributesAtIndexEffectiveRange(
- initWithCoder: aCoder - initWithCoder: aCoder
{ {
self = [super initWithCoder:aCoder]; self = [super initWithCoder:aCoder];
textChars = [[aCoder decodeObject] retain]; [aCoder decodeValueOfObjCType: @encode(id) at: &textChars];
attributeArray = [[aCoder decodeObject] retain]; [aCoder decodeValueOfObjCType: @encode(id) at: &attributeArray];
locateArray = [[aCoder decodeObject] retain]; [aCoder decodeValueOfObjCType: @encode(id) at: &locateArray];
return self; return self;
} }

View file

@ -139,7 +139,7 @@ static NSMutableDictionary *_hostCache = nil;
+ (void)initialize + (void)initialize
{ {
_hostCacheLock = [[NSConditionLock alloc] init]; _hostCacheLock = [[NSConditionLock alloc] init];
_hostCache = [[NSMutableDictionary dictionary] retain]; _hostCache = [NSMutableDictionary new];
} }
+ (NSHost *)currentHost + (NSHost *)currentHost
@ -246,7 +246,6 @@ static NSMutableDictionary *_hostCache = nil;
[super initWithCoder: aCoder]; [super initWithCoder: aCoder];
address = [aCoder decodeObject]; address = [aCoder decodeObject];
addresses = [NSArray arrayWithObject: address]; addresses = [NSArray arrayWithObject: address];
[address release];
return self; return self;
} }
#endif #endif

View file

@ -26,6 +26,7 @@
#include <Foundation/NSDate.h> #include <Foundation/NSDate.h>
#include <Foundation/NSException.h> #include <Foundation/NSException.h>
#include <Foundation/NSProcessInfo.h> #include <Foundation/NSProcessInfo.h>
#include <Foundation/NSAutoreleasePool.h>
#ifndef __WIN32__ #ifndef __WIN32__
#include <unistd.h> #include <unistd.h>
@ -52,6 +53,7 @@ NSLog (NSString* format, ...)
void void
NSLogv (NSString* format, va_list args) NSLogv (NSString* format, va_list args)
{ {
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSString* prefix; NSString* prefix;
NSString* message; NSString* message;
@ -72,5 +74,6 @@ NSLogv (NSString* format, va_list args)
prefix = [prefix stringByAppendingString: message]; prefix = [prefix stringByAppendingString: message];
_NSLog_printf_handler (prefix); _NSLog_printf_handler (prefix);
[arp release];
} }

View file

@ -70,6 +70,7 @@
#include <Foundation/NSDate.h> #include <Foundation/NSDate.h>
#include <Foundation/NSException.h> #include <Foundation/NSException.h>
#include <Foundation/NSProcessInfo.h> #include <Foundation/NSProcessInfo.h>
#include <Foundation/NSAutoreleasePool.h>
/* This error message should be called only if the private main function /* This error message should be called only if the private main function
* was not executed successfully. This may heppen ONLY if onother library * was not executed successfully. This may heppen ONLY if onother library
@ -138,6 +139,7 @@ static NSMutableArray* _debug_array = nil;
static void static void
_gnu_process_args(int argc, char *argv[], char *env[]) _gnu_process_args(int argc, char *argv[], char *env[])
{ {
NSAutoreleasePool *arp = [NSAutoreleasePool new];
int i; int i;
/* Getting the process name */ /* Getting the process name */
@ -187,6 +189,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
[keys release]; [keys release];
[values release]; [values release];
} }
[arp release];
} }
/* Place the _gnu_process_args function in the _libc_subinit section so /* Place the _gnu_process_args function in the _libc_subinit section so

View file

@ -344,7 +344,7 @@ decode (const void *ptr)
- initWithDecoder: aDecoder - initWithDecoder: aDecoder
{ {
self = [super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
name = [aDecoder decodeObject]; [aDecoder decodeValueOfObjCType: @encode(id) at: &name];
return self; return self;
} }
@ -425,7 +425,7 @@ decode (const void *ptr)
- initWithCoder: aDecoder - initWithCoder: aDecoder
{ {
self = [super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
name = [aDecoder decodeObject]; [aDecoder decodeValueOfObjCType: @encode(id) at: &name];
offset = [name intValue]; offset = [name intValue];
return self; return self;
} }
@ -479,7 +479,7 @@ decode (const void *ptr)
- initWithCoder: aDecoder - initWithCoder: aDecoder
{ {
self = [super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];
abbrev = [aDecoder decodeObject]; [aDecoder decodeValueOfObjCType: @encode(id) at: &abbrev];
[aDecoder decodeValueOfObjCType: @encode(int) at: &offset]; [aDecoder decodeValueOfObjCType: @encode(int) at: &offset];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &is_dst]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &is_dst];
return self; return self;