mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Some more leak improvements
This commit is contained in:
parent
dd3367de3b
commit
25505b2e67
5 changed files with 90 additions and 43 deletions
|
@ -632,6 +632,15 @@ static Class concreteMutableClass = nil;
|
|||
return abstractClass;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
if (cache_map[_index] == self)
|
||||
{
|
||||
cache_map[_index] = nil;
|
||||
}
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[aCoder encodeValueOfObjCType: @encode(int) at: &_index];
|
||||
|
@ -707,6 +716,20 @@ static Class concreteMutableClass = nil;
|
|||
|
||||
@implementation NSCharacterSet
|
||||
|
||||
static gs_mutex_t cache_lock = GS_MUTEX_INIT_STATIC;
|
||||
|
||||
+ (void) atExit
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < MAX_STANDARD_SETS; i++)
|
||||
{
|
||||
GS_MUTEX_LOCK(cache_lock);
|
||||
DESTROY(cache_set[i]);
|
||||
GS_MUTEX_UNLOCK(cache_lock);
|
||||
}
|
||||
}
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
static BOOL beenHere = NO;
|
||||
|
@ -723,6 +746,7 @@ static Class concreteMutableClass = nil;
|
|||
concreteMutableClass = [NSMutableBitmapCharSet class];
|
||||
#endif
|
||||
beenHere = YES;
|
||||
[self registerAtExit];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -735,7 +759,7 @@ static Class concreteMutableClass = nil;
|
|||
length: (unsigned)length
|
||||
number: (int)number
|
||||
{
|
||||
static gs_mutex_t cache_lock = GS_MUTEX_INIT_STATIC;
|
||||
NSCharacterSet *set;
|
||||
|
||||
GS_MUTEX_LOCK(cache_lock);
|
||||
if (cache_set[number] == nil && bytes != 0)
|
||||
|
@ -747,11 +771,11 @@ static Class concreteMutableClass = nil;
|
|||
freeWhenDone: NO];
|
||||
cache_set[number]
|
||||
= [[_GSStaticCharSet alloc] initWithBitmap: bitmap number: number];
|
||||
[[NSObject leakAt: &cache_set[number]] release];
|
||||
RELEASE(bitmap);
|
||||
}
|
||||
set = RETAIN(cache_set[number]);
|
||||
GS_MUTEX_UNLOCK(cache_lock);
|
||||
return cache_set[number];
|
||||
return AUTORELEASE(set);
|
||||
}
|
||||
|
||||
+ (id) alphanumericCharacterSet
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue