mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Minor usability tweak.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@18240 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
26a9b924d7
commit
d2936869b9
2 changed files with 35 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
|||
2003-11-30 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSNumber.m: Raise exception if user code incorrectly tries
|
||||
to deallocate a cached small number.
|
||||
|
||||
2003-11-25 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/Additions/GSMime.m: fix for incremental parsing so that
|
||||
|
|
|
@ -41,6 +41,33 @@
|
|||
|
||||
#include "NSConcreteNumber.h"
|
||||
|
||||
@interface GSCachedBool : NSBoolNumber
|
||||
@end
|
||||
@interface GSCachedInt : NSIntNumber
|
||||
@end
|
||||
@implementation GSCachedBool
|
||||
- (id) copyWithZone: (NSZone*)zone
|
||||
{
|
||||
return RETAIN(self);
|
||||
}
|
||||
- (void) dealloc
|
||||
{
|
||||
[NSException raise: NSGenericException
|
||||
format: @"Attempt to deallocate bool number owned by cache"];
|
||||
}
|
||||
@end
|
||||
@implementation GSCachedInt
|
||||
- (id) copyWithZone: (NSZone*)zone
|
||||
{
|
||||
return RETAIN(self);
|
||||
}
|
||||
- (void) dealloc
|
||||
{
|
||||
[NSException raise: NSGenericException
|
||||
format: @"Attempt to deallocate int number owned by cache"];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSNumber
|
||||
|
||||
static NSMapTable *numberMap;
|
||||
|
@ -204,12 +231,12 @@ static Class doubleNumberClass;
|
|||
/*
|
||||
* cache bool values.
|
||||
*/
|
||||
boolN = (NSNumber*)NSAllocateObject(boolNumberClass, 0,
|
||||
boolN = (NSNumber*)NSAllocateObject([GSCachedBool class], 0,
|
||||
NSDefaultMallocZone());
|
||||
boolean = NO;
|
||||
boolN = [boolN initWithBytes: &boolean objCType: NULL];
|
||||
|
||||
boolY = (NSNumber*)NSAllocateObject(boolNumberClass, 0,
|
||||
boolY = (NSNumber*)NSAllocateObject([GSCachedBool class], 0,
|
||||
NSDefaultMallocZone());
|
||||
boolean = YES;
|
||||
boolY = [boolY initWithBytes: &boolean objCType: NULL];
|
||||
|
@ -221,7 +248,7 @@ static Class doubleNumberClass;
|
|||
{
|
||||
NSNumber *num;
|
||||
|
||||
num = (NSNumber*)NSAllocateObject(intNumberClass, 0,
|
||||
num = (NSNumber*)NSAllocateObject([GSCachedInt class], 0,
|
||||
NSDefaultMallocZone());
|
||||
num = [num initWithBytes: &integer objCType: NULL];
|
||||
smallIntegers[integer + GS_SMALL] = num;
|
||||
|
|
Loading…
Reference in a new issue