mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Fix memory leak
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@15953 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
98db676835
commit
34eab5ea3f
3 changed files with 23 additions and 7 deletions
|
@ -1,3 +1,8 @@
|
|||
2003-02-13 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSTimeZone.m: Fix memory leak when making absolute
|
||||
timezone for offset 0.
|
||||
|
||||
2003-02-11 Tom Koelman <tkoelman@xs4all.nl>
|
||||
|
||||
* Source/NSTask.m: Make arguments into windows quoted strings for
|
||||
|
|
|
@ -121,7 +121,6 @@ GSIArray.h \
|
|||
GSIMap.h \
|
||||
Unicode.h \
|
||||
behavior.h \
|
||||
numbers.h \
|
||||
objc-gnu2next.h \
|
||||
preface.h
|
||||
|
||||
|
|
|
@ -539,6 +539,7 @@ decode (const void *ptr)
|
|||
|
||||
@implementation GSAbsTimeZone
|
||||
|
||||
static int uninitialisedOffset = 100000;
|
||||
static NSMapTable *absolutes = 0;
|
||||
|
||||
+ (void) initialize
|
||||
|
@ -557,11 +558,14 @@ static NSMapTable *absolutes = 0;
|
|||
|
||||
- (void) dealloc
|
||||
{
|
||||
if (zone_mutex != nil)
|
||||
[zone_mutex lock];
|
||||
NSMapRemove(absolutes, (void*)(gsaddr)offset);
|
||||
if (zone_mutex != nil)
|
||||
[zone_mutex unlock];
|
||||
if (offset != uninitialisedOffset)
|
||||
{
|
||||
if (zone_mutex != nil)
|
||||
[zone_mutex lock];
|
||||
NSMapRemove(absolutes, (void*)(gsaddr)offset);
|
||||
if (zone_mutex != nil)
|
||||
[zone_mutex unlock];
|
||||
}
|
||||
RELEASE(name);
|
||||
RELEASE(detail);
|
||||
[super dealloc];
|
||||
|
@ -578,6 +582,12 @@ static NSMapTable *absolutes = 0;
|
|||
int extra;
|
||||
int sign = anOffset >= 0 ? 1 : -1;
|
||||
|
||||
/*
|
||||
* Set the uninitialised offset so that dealloc before full
|
||||
* initialisation won't remove the timezeone for offset 0 from cache.
|
||||
*/
|
||||
offset = uninitialisedOffset;
|
||||
|
||||
/*
|
||||
* Round the offset to the nearest minute, (for MacOS-X compatibility)
|
||||
* and ensure it is no more than 18 hours.
|
||||
|
@ -617,8 +627,10 @@ static NSMapTable *absolutes = 0;
|
|||
int i = (anOffset >= 0) ? anOffset / 60 : -anOffset / 60;
|
||||
int h = i / 60;
|
||||
int m = i % 60;
|
||||
char buf[9];
|
||||
|
||||
name = [[NSString alloc] initWithFormat: @"GMT%c%02d%02d", s, h, m];
|
||||
sprintf(buf, "GMT%c%02d%02d", s, h, m);
|
||||
name = [[NSString alloc] initWithCString: buf];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue