mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
further cleanup ... always use -zone method to get an object's zone ...
so people can safely write subclasses using different allocation schemes. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29847 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4451967349
commit
39fc4419b0
22 changed files with 133 additions and 108 deletions
21
ChangeLog
21
ChangeLog
|
@ -1,3 +1,24 @@
|
|||
2010-03-05 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSArray.m:
|
||||
* Source/GSDictionary.m:
|
||||
* Source/NSURLProtocol.m:
|
||||
* Source/NSNotificationCenter.m:
|
||||
* Source/GSAttributedString.m:
|
||||
* Source/NSURL.m:
|
||||
* Source/NSObject.m:
|
||||
* Source/NSString.m:
|
||||
* Source/Additions/NSAttributedString+GNUstepBase.m:
|
||||
* Source/Additions/GSInsensitiveDictionary.m:
|
||||
* Source/GSString.m:
|
||||
* Source/NSData.m:
|
||||
* Source/GSValue.m:
|
||||
* Source/NSValue.m:
|
||||
* Source/NSArchiver.m:
|
||||
* Source/NSURLConnection.m:
|
||||
* Headers/Additions/GNUstepBase/GSObjCRuntime.h:
|
||||
Remove reference to GSObjCZone and use -zone instead.
|
||||
|
||||
2010-03-05 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Additions/GNUstepBase/GSObjCRuntime.h:
|
||||
|
|
|
@ -47,42 +47,10 @@
|
|||
#include <ObjectiveC2/runtime.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef GNUSTEP_WITH_DLL
|
||||
|
||||
#if BUILD_libgnustep_base_DLL
|
||||
#
|
||||
# if defined(__MINGW32__)
|
||||
/* On Mingw, the compiler will export all symbols automatically, so
|
||||
* __declspec(dllexport) is not needed.
|
||||
*/
|
||||
# define GS_EXPORT extern
|
||||
# define GS_DECLARE
|
||||
# else
|
||||
# define GS_EXPORT __declspec(dllexport)
|
||||
# define GS_DECLARE __declspec(dllexport)
|
||||
# endif
|
||||
#else
|
||||
# define GS_EXPORT extern __declspec(dllimport)
|
||||
# define GS_DECLARE __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#else /* GNUSTEP_WITH[OUT]_DLL */
|
||||
|
||||
# define GS_EXPORT extern
|
||||
# define GS_DECLARE
|
||||
|
||||
#endif
|
||||
|
||||
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
#define GS_ATTRIB_DEPRECATED __attribute__ ((deprecated))
|
||||
#else
|
||||
#define GS_ATTRIB_DEPRECATED
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@class NSArray;
|
||||
|
@ -346,13 +314,6 @@ GSObjCGetInstanceVariableDefinition(Class cls, NSString *name);
|
|||
*/
|
||||
GS_EXPORT int GSObjCVersion(Class cls);
|
||||
|
||||
#import <Foundation/NSZone.h>
|
||||
/**
|
||||
* GSObjCZone() is deprecated ... use -zone
|
||||
*/
|
||||
GS_EXPORT NSZone *
|
||||
GSObjCZone(NSObject *obj);
|
||||
|
||||
/**
|
||||
* Quickly return autoreleased data storage area.
|
||||
*/
|
||||
|
|
|
@ -206,4 +206,40 @@
|
|||
|
||||
#define GS_EXPOSE(X) (!GS_NONFRAGILE || defined(EXPOSE_##X##_IVARS))
|
||||
|
||||
|
||||
|
||||
|
||||
#if defined(GNUSTEP_WITH_DLL)
|
||||
|
||||
#if BUILD_libgnustep_base_DLL
|
||||
#
|
||||
# if defined(__MINGW32__)
|
||||
/* On Mingw, the compiler will export all symbols automatically, so
|
||||
* __declspec(dllexport) is not needed.
|
||||
*/
|
||||
# define GS_EXPORT extern
|
||||
# define GS_DECLARE
|
||||
# else
|
||||
# define GS_EXPORT __declspec(dllexport)
|
||||
# define GS_DECLARE __declspec(dllexport)
|
||||
# endif
|
||||
#else
|
||||
# define GS_EXPORT extern __declspec(dllimport)
|
||||
# define GS_DECLARE __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#else /* GNUSTEP_WITH[OUT]_DLL */
|
||||
|
||||
# define GS_EXPORT extern
|
||||
# define GS_DECLARE
|
||||
|
||||
#endif
|
||||
|
||||
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
#define GS_ATTRIB_DEPRECATED __attribute__ ((deprecated))
|
||||
#else
|
||||
#define GS_ATTRIB_DEPRECATED
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __GNUSTEP_GSVERSIONMACROS_H_INCLUDED_ */
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#ifndef __Unicode_h_OBJECTS_INCLUDE
|
||||
#define __Unicode_h_OBJECTS_INCLUDE
|
||||
#include <GNUstepBase/GSVersionMacros.h>
|
||||
#include <GNUstepBase/GSObjCRuntime.h>
|
||||
|
||||
#import <Foundation/NSString.h> /* For standard string encodings */
|
||||
|
||||
|
|
|
@ -56,8 +56,6 @@ typedef float CGFloat;
|
|||
#define NSINTEGER_DEFINED 1
|
||||
#define CGFLOAT_DEFINED 1
|
||||
|
||||
#import <GNUstepBase/GSObjCRuntime.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -81,6 +79,8 @@ enum
|
|||
*/
|
||||
typedef NSUInteger NSEnumerationOptions;
|
||||
|
||||
#include <GNUstepBase/GSObjCRuntime.h>
|
||||
|
||||
#if OS_API_VERSION(100500,GS_API_LATEST)
|
||||
GS_EXPORT NSString *NSStringFromProtocol(Protocol *aProtocol);
|
||||
GS_EXPORT Protocol *NSProtocolFromString(NSString *aProtocolName);
|
||||
|
|
|
@ -27,8 +27,7 @@
|
|||
#ifndef __NSPathUtilities_h_GNUSTEP_BASE_INCLUDE
|
||||
#define __NSPathUtilities_h_GNUSTEP_BASE_INCLUDE
|
||||
#import <GNUstepBase/GSVersionMacros.h>
|
||||
|
||||
#import <GNUstepBase/GSObjCRuntime.h>
|
||||
#import <Foundation/NSObjCRuntime.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
|
|
|
@ -157,7 +157,7 @@ static SEL objSel;
|
|||
[aCoder decodeValueOfObjCType: @encode(NSUInteger)
|
||||
at: &count];
|
||||
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSObjCZone(self), count);
|
||||
GSIMapInitWithZoneAndCapacity(&map, [self zone], count);
|
||||
while (count-- > 0)
|
||||
{
|
||||
(*imp)(aCoder, sel, type, &key);
|
||||
|
@ -173,7 +173,7 @@ static SEL objSel;
|
|||
{
|
||||
NSUInteger i;
|
||||
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSObjCZone(self), c);
|
||||
GSIMapInitWithZoneAndCapacity(&map, [self zone], c);
|
||||
for (i = 0; i < c; i++)
|
||||
{
|
||||
GSIMapNode node;
|
||||
|
@ -212,7 +212,7 @@ static SEL objSel;
|
|||
- (id) initWithDictionary: (NSDictionary*)other
|
||||
copyItems: (BOOL)shouldCopy
|
||||
{
|
||||
NSZone *z = GSObjCZone(self);
|
||||
NSZone *z = [self zone];
|
||||
NSUInteger c = [other count];
|
||||
|
||||
GSIMapInitWithZoneAndCapacity(&map, z, c);
|
||||
|
@ -366,7 +366,7 @@ static SEL objSel;
|
|||
/* Designated initialiser */
|
||||
- (id) initWithCapacity: (NSUInteger)cap
|
||||
{
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSObjCZone(self), cap);
|
||||
GSIMapInitWithZoneAndCapacity(&map, [self zone], cap);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
*/
|
||||
#import "common.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "GNUstepBase/NSAttributedString+GNUstepBase.h"
|
||||
#import "GNUstepBase/NSDebug+GNUstepBase.h"
|
||||
|
|
|
@ -1140,14 +1140,14 @@ static Class GSInlineArrayClass;
|
|||
GSArray *a;
|
||||
|
||||
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &c];
|
||||
a = (id)NSAllocateObject(GSArrayClass, 0, GSObjCZone(self));
|
||||
a = (id)NSAllocateObject(GSArrayClass, 0, [self zone]);
|
||||
a->_contents_array = NSAllocateCollectable(sizeof(id)*c, NSScannedOption);
|
||||
#else
|
||||
GSInlineArray *a;
|
||||
|
||||
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &c];
|
||||
a = (id)NSAllocateObject(GSInlineArrayClass,
|
||||
sizeof(id)*c, GSObjCZone(self));
|
||||
sizeof(id)*c, [self zone]);
|
||||
a->_contents_array
|
||||
= (id*)(((void*)a) + class_getInstanceSize([a class]));
|
||||
#endif
|
||||
|
@ -1165,10 +1165,10 @@ static Class GSInlineArrayClass;
|
|||
- (id) initWithObjects: (id*)objects count: (unsigned)count
|
||||
{
|
||||
#if GS_WITH_GC
|
||||
self = (id)NSAllocateObject(GSArrayClass, 0, GSObjCZone(self));
|
||||
self = (id)NSAllocateObject(GSArrayClass, 0, [self zone]);
|
||||
#else
|
||||
self = (id)NSAllocateObject(GSInlineArrayClass, sizeof(id)*count,
|
||||
GSObjCZone(self));
|
||||
[self zone]);
|
||||
#endif
|
||||
return [self initWithObjects: objects count: count];
|
||||
}
|
||||
|
|
|
@ -324,7 +324,7 @@ _setAttributesFrom(
|
|||
NSRange aRange,
|
||||
NSMutableArray *_infoArray)
|
||||
{
|
||||
NSZone *z = GSObjCZone(_infoArray);
|
||||
NSZone *z = [_infoArray zone];
|
||||
NSRange range;
|
||||
NSDictionary *attr;
|
||||
GSAttrInfo *info;
|
||||
|
@ -459,7 +459,7 @@ _attributesAtIndexEffectiveRange(
|
|||
- (id) initWithString: (NSString*)aString
|
||||
attributes: (NSDictionary*)attributes
|
||||
{
|
||||
NSZone *z = GSObjCZone(self);
|
||||
NSZone *z = [self zone];
|
||||
|
||||
_infoArray = [[NSMutableArray allocWithZone: z] initWithCapacity: 1];
|
||||
if (aString != nil && [aString isKindOfClass: [NSAttributedString class]])
|
||||
|
@ -560,7 +560,7 @@ _attributesAtIndexEffectiveRange(
|
|||
- (id) initWithString: (NSString*)aString
|
||||
attributes: (NSDictionary*)attributes
|
||||
{
|
||||
NSZone *z = GSObjCZone(self);
|
||||
NSZone *z = [self zone];
|
||||
|
||||
_infoArray = [[NSMutableArray allocWithZone: z] initWithCapacity: 1];
|
||||
if (aString != nil && [aString isKindOfClass: [NSAttributedString class]])
|
||||
|
@ -629,7 +629,7 @@ SANITY();
|
|||
NSRange effectiveRange;
|
||||
unsigned afterRangeLoc, beginRangeLoc;
|
||||
NSDictionary *attrs;
|
||||
NSZone *z = GSObjCZone(self);
|
||||
NSZone *z = [self zone];
|
||||
GSAttrInfo *info;
|
||||
|
||||
if (range.length == 0)
|
||||
|
|
|
@ -171,7 +171,7 @@ static SEL objSel;
|
|||
[aCoder decodeValueOfObjCType: @encode(unsigned)
|
||||
at: &count];
|
||||
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSObjCZone(self), count);
|
||||
GSIMapInitWithZoneAndCapacity(&map, [self zone], count);
|
||||
while (count-- > 0)
|
||||
{
|
||||
(*imp)(aCoder, sel, type, &key);
|
||||
|
@ -187,7 +187,7 @@ static SEL objSel;
|
|||
{
|
||||
unsigned int i;
|
||||
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSObjCZone(self), c);
|
||||
GSIMapInitWithZoneAndCapacity(&map, [self zone], c);
|
||||
for (i = 0; i < c; i++)
|
||||
{
|
||||
GSIMapNode node;
|
||||
|
@ -226,7 +226,7 @@ static SEL objSel;
|
|||
- (id) initWithDictionary: (NSDictionary*)other
|
||||
copyItems: (BOOL)shouldCopy
|
||||
{
|
||||
NSZone *z = GSObjCZone(self);
|
||||
NSZone *z = [self zone];
|
||||
unsigned c = [other count];
|
||||
|
||||
GSIMapInitWithZoneAndCapacity(&map, z, c);
|
||||
|
@ -388,7 +388,7 @@ static SEL objSel;
|
|||
/* Designated initialiser */
|
||||
- (id) initWithCapacity: (unsigned)cap
|
||||
{
|
||||
GSIMapInitWithZoneAndCapacity(&map, GSObjCZone(self), cap);
|
||||
GSIMapInitWithZoneAndCapacity(&map, [self zone], cap);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -485,7 +485,7 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
|||
#if GS_WITH_GC
|
||||
chars = NSAllocateCollectable(length, 0);
|
||||
#else
|
||||
chars = NSZoneMalloc(GSObjCZone(self), length);
|
||||
chars = NSZoneMalloc([self zone], length);
|
||||
#endif
|
||||
memcpy(chars, bytes, length);
|
||||
}
|
||||
|
@ -595,7 +595,7 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
|||
if (GSPrivateIsCollectable(chars.c) == NO)
|
||||
{
|
||||
me = (GSStr)NSAllocateObject(GSCInlineStringClass, length,
|
||||
GSObjCZone(self));
|
||||
[self zone]);
|
||||
me->_contents.c = (unsigned char*)&((GSCInlineString*)me)[1];
|
||||
me->_count = length;
|
||||
me->_flags.wide = 0;
|
||||
|
@ -605,7 +605,7 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
|||
return (id)me;
|
||||
}
|
||||
#endif
|
||||
me = (GSStr)NSAllocateObject(GSCBufferStringClass, 0, GSObjCZone(self));
|
||||
me = (GSStr)NSAllocateObject(GSCBufferStringClass, 0, [self zone]);
|
||||
me->_contents.c = chars.c;
|
||||
me->_count = length;
|
||||
me->_flags.wide = 0;
|
||||
|
@ -622,7 +622,7 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
|||
unsigned l = 0;
|
||||
|
||||
if (GSToUnicode(&u, &l, chars.c, length, encoding,
|
||||
GSObjCZone(self), 0) == NO)
|
||||
[self zone], 0) == NO)
|
||||
{
|
||||
if (flag == YES && chars.c != 0)
|
||||
{
|
||||
|
@ -653,7 +653,7 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
|||
|| (internalEncoding == NSISOLatin1StringEncoding && isLatin1 == YES))
|
||||
{
|
||||
me = (GSStr)NSAllocateObject(GSCInlineStringClass, length,
|
||||
GSObjCZone(self));
|
||||
[self zone]);
|
||||
me->_contents.c = (unsigned char*)
|
||||
(((void*)me)+class_getInstanceSize(GSCInlineStringClass));
|
||||
me->_count = length;
|
||||
|
@ -677,7 +677,7 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
|||
if (GSPrivateIsCollectable(chars.u) == NO)
|
||||
{
|
||||
me = (GSStr)NSAllocateObject(GSUnicodeInlineStringClass, length,
|
||||
GSObjCZone(self));
|
||||
[self zone]);
|
||||
me->_contents.u = (unichar*)&((GSUnicodeInlineString*)me)[1];
|
||||
me->_count = length;
|
||||
me->_flags.wide = 1;
|
||||
|
@ -688,7 +688,7 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
|||
}
|
||||
#endif
|
||||
me = (GSStr)NSAllocateObject(GSUnicodeBufferStringClass,
|
||||
0, GSObjCZone(self));
|
||||
0, [self zone]);
|
||||
me->_contents.u = chars.u;
|
||||
me->_count = length;
|
||||
me->_flags.wide = 1;
|
||||
|
@ -787,7 +787,7 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
|||
if (f->_flags.wide == 1)
|
||||
{
|
||||
me = (GSStr)NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
f->_count*sizeof(unichar), GSObjCZone(self));
|
||||
f->_count*sizeof(unichar), [self zone]);
|
||||
me->_contents.u = (unichar*)
|
||||
(((void*)me)+class_getInstanceSize(GSUnicodeInlineStringClass));
|
||||
me->_count = f->_count;
|
||||
|
@ -798,7 +798,7 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
|||
else
|
||||
{
|
||||
me = (GSStr)NSAllocateObject(GSCInlineStringClass, f->_count,
|
||||
GSObjCZone(self));
|
||||
[self zone]);
|
||||
me->_contents.c = (unsigned char*)
|
||||
(((void*)me)+class_getInstanceSize(GSCInlineStringClass));
|
||||
me->_count = f->_count;
|
||||
|
@ -846,7 +846,7 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
|||
* GSMutableString, we can copy the bytes directly into a GSCString.
|
||||
*/
|
||||
me = (GSStr)NSAllocateObject(GSCInlineStringClass,
|
||||
length, GSObjCZone(self));
|
||||
length, [self zone]);
|
||||
me->_contents.c = (unsigned char*)
|
||||
(((void*)me)+class_getInstanceSize(GSCInlineStringClass));
|
||||
me->_count = length;
|
||||
|
@ -862,7 +862,7 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
|||
* we can copy the bytes directly into a GSUnicodeString.
|
||||
*/
|
||||
me = (GSStr)NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
length*sizeof(unichar), GSObjCZone(self));
|
||||
length*sizeof(unichar), [self zone]);
|
||||
me->_contents.u = (unichar*)
|
||||
(((void*)me)+class_getInstanceSize(GSUnicodeInlineStringClass));
|
||||
me->_count = length;
|
||||
|
@ -878,7 +878,7 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
|||
* having the string copy its content directly into our buffer.
|
||||
*/
|
||||
me = (GSStr)NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
length*sizeof(unichar), GSObjCZone(self));
|
||||
length*sizeof(unichar), [self zone]);
|
||||
me->_contents.u = (unichar*)
|
||||
(((void*)me)+class_getInstanceSize(GSUnicodeInlineStringClass));
|
||||
me->_count = length;
|
||||
|
@ -2358,7 +2358,7 @@ static void GSStrMakeSpace(GSStr s, unsigned size)
|
|||
#if GS_WITH_GC
|
||||
s->_zone = GSAtomicMallocZone();
|
||||
#else
|
||||
s->_zone = GSObjCZone((NSString*)s);
|
||||
s->_zone = [(NSString*)s zone];
|
||||
#endif
|
||||
}
|
||||
if (s->_flags.wide == 1)
|
||||
|
@ -2419,7 +2419,7 @@ static void GSStrWiden(GSStr s)
|
|||
#if GS_WITH_GC
|
||||
s->_zone = GSAtomicMallocZone();
|
||||
#else
|
||||
s->_zone = GSObjCZone((NSString*)s);
|
||||
s->_zone = [(NSString*)s zone];
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -2897,7 +2897,7 @@ transmute(GSStr self, NSString *aString)
|
|||
{
|
||||
if (length > 0)
|
||||
{
|
||||
void *tmp = NSZoneMalloc(GSObjCZone(self), length);
|
||||
void *tmp = NSZoneMalloc([self zone], length);
|
||||
|
||||
memcpy(tmp, chars, length);
|
||||
chars = tmp;
|
||||
|
@ -3670,7 +3670,7 @@ agree, create a new GSUnicodeInlineString otherwise.
|
|||
#if GS_WITH_GC
|
||||
_zone = GSAtomicMallocZone();
|
||||
#else
|
||||
_zone = GSObjCZone(self);
|
||||
_zone = [self zone];
|
||||
#endif
|
||||
}
|
||||
GSPrivateFormat((GSStr)self, fmt, ap, nil);
|
||||
|
@ -3949,7 +3949,7 @@ NSAssert(_flags.owned == 1 && _zone != 0, NSInternalInconsistencyException);
|
|||
#if GS_WITH_GC
|
||||
_zone = GSAtomicMallocZone();
|
||||
#else
|
||||
_zone = GSObjCZone(self);
|
||||
_zone = [self zone];
|
||||
#endif
|
||||
|
||||
if (length > 0)
|
||||
|
@ -4118,7 +4118,7 @@ NSAssert(_flags.owned == 1 && _zone != 0, NSInternalInconsistencyException);
|
|||
#if GS_WITH_GC
|
||||
_zone = GSAtomicMallocZone();
|
||||
#else
|
||||
_zone = GSObjCZone(self);
|
||||
_zone = [self zone];
|
||||
#endif
|
||||
_contents.c = NSZoneMalloc(_zone, capacity + 1);
|
||||
_flags.wide = 0;
|
||||
|
|
|
@ -97,10 +97,10 @@ typeSize(const char* type)
|
|||
}
|
||||
if (size > 0)
|
||||
{
|
||||
data = (void *)NSZoneMalloc(GSObjCZone(self), size);
|
||||
data = (void *)NSZoneMalloc([self zone], size);
|
||||
memcpy(data, value, size);
|
||||
}
|
||||
objctype = (char *)NSZoneMalloc(GSObjCZone(self), strlen(type)+1);
|
||||
objctype = (char *)NSZoneMalloc([self zone], strlen(type)+1);
|
||||
strcpy(objctype, type);
|
||||
}
|
||||
return self;
|
||||
|
@ -109,9 +109,9 @@ typeSize(const char* type)
|
|||
- (void) dealloc
|
||||
{
|
||||
if (objctype != 0)
|
||||
NSZoneFree(GSObjCZone(self), objctype);
|
||||
NSZoneFree([self zone], objctype);
|
||||
if (data != 0)
|
||||
NSZoneFree(GSObjCZone(self), data);
|
||||
NSZoneFree([self zone], data);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ static Class NSMutableDataMallocClass;
|
|||
{
|
||||
NSMutableData *d;
|
||||
|
||||
d = [[NSMutableDataMallocClass allocWithZone: GSObjCZone(self)] init];
|
||||
d = [[NSMutableDataMallocClass allocWithZone: [self zone]] init];
|
||||
self = [self initForWritingWithMutableData: d];
|
||||
RELEASE(d);
|
||||
return self;
|
||||
|
|
|
@ -619,7 +619,7 @@ failure:
|
|||
return nil;
|
||||
}
|
||||
#else
|
||||
if (readContentsOfFile(path, &fileBytes, &fileLength, GSObjCZone(self)) == NO)
|
||||
if (readContentsOfFile(path, &fileBytes, &fileLength, [self zone]) == NO)
|
||||
{
|
||||
DESTROY(self);
|
||||
return nil;
|
||||
|
@ -639,7 +639,7 @@ failure:
|
|||
- (id) initWithContentsOfMappedFile: (NSString *)path
|
||||
{
|
||||
#ifdef HAVE_MMAP
|
||||
NSZone *z = GSObjCZone(self);
|
||||
NSZone *z = [self zone];
|
||||
DESTROY(self);
|
||||
self = [NSDataMappedFile allocWithZone: z];
|
||||
return [self initWithContentsOfMappedFile: path];
|
||||
|
@ -1911,7 +1911,7 @@ failure:
|
|||
#if GS_WITH_GC
|
||||
b = NSAllocateCollectable(l, 0);
|
||||
#else
|
||||
b = NSZoneMalloc(GSObjCZone(self), l);
|
||||
b = NSZoneMalloc([self zone], l);
|
||||
#endif
|
||||
if (b == 0)
|
||||
{
|
||||
|
@ -3292,7 +3292,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
#if GS_WITH_GC
|
||||
bytes = NSAllocateCollectable(size, 0);
|
||||
#else
|
||||
zone = GSObjCZone(self);
|
||||
zone = [self zone];
|
||||
bytes = NSZoneMalloc(zone, size);
|
||||
#endif
|
||||
if (bytes == 0)
|
||||
|
|
|
@ -70,7 +70,7 @@ static Class concrete = 0;
|
|||
GSNotification *n;
|
||||
|
||||
n = (GSNotification*)NSAllocateObject(self, 0, NSDefaultMallocZone());
|
||||
n->_name = [name copyWithZone: GSObjCZone(self)];
|
||||
n->_name = [name copyWithZone: [self zone]];
|
||||
n->_object = TEST_RETAIN(object);
|
||||
n->_info = TEST_RETAIN(info);
|
||||
return AUTORELEASE(n);
|
||||
|
@ -85,7 +85,7 @@ static Class concrete = 0;
|
|||
return [self retain];
|
||||
}
|
||||
n = (GSNotification*)NSAllocateObject(concrete, 0, NSDefaultMallocZone());
|
||||
n->_name = [_name copyWithZone: GSObjCZone(self)];
|
||||
n->_name = [_name copyWithZone: [self zone]];
|
||||
n->_object = TEST_RETAIN(_object);
|
||||
n->_info = TEST_RETAIN(_info);
|
||||
return n;
|
||||
|
@ -1214,7 +1214,7 @@ static NSNotificationCenter *default_center = nil;
|
|||
GSNotification *notification;
|
||||
|
||||
notification = (id)NSAllocateObject(concrete, 0, NSDefaultMallocZone());
|
||||
name = notification->_name = [name copyWithZone: GSObjCZone(self)];
|
||||
name = notification->_name = [name copyWithZone: [self zone]];
|
||||
object = notification->_object = TEST_RETAIN(object);
|
||||
notification->_info = TEST_RETAIN(info);
|
||||
[self _postAndRelease: notification];
|
||||
|
|
|
@ -525,6 +525,7 @@ NSIncrementExtraRefCount(id anObject)
|
|||
inline NSZone *
|
||||
GSObjCZone(NSObject *object)
|
||||
{
|
||||
GSOnceFLog(@"GSObjCZone() is deprecated ... use -zone instead");
|
||||
/* MacOS-X 10.5 seems to return the default malloc zone if GC is enabled.
|
||||
*/
|
||||
return NSDefaultMallocZone();
|
||||
|
@ -601,6 +602,7 @@ NSDeallocateObject(id anObject)
|
|||
inline NSZone *
|
||||
GSObjCZone(NSObject *object)
|
||||
{
|
||||
GSOnceFLog(@"GSObjCZone() is deprecated ... use -zone instead");
|
||||
if (object_getClass(object) == NSConstantStringClass)
|
||||
return NSDefaultMallocZone();
|
||||
return ((obj)object)[-1].zone;
|
||||
|
@ -636,7 +638,7 @@ NSDeallocateObject(id anObject)
|
|||
if ((anObject!=nil) && CLS_ISCLASS(((id)anObject)->class_pointer))
|
||||
{
|
||||
obj o = &((obj)anObject)[-1];
|
||||
NSZone *z = GSObjCZone(anObject);
|
||||
NSZone *z = o->zone;
|
||||
|
||||
AREM(((id)anObject)->class_pointer, (id)anObject);
|
||||
if (NSZombieEnabled == YES)
|
||||
|
@ -701,7 +703,7 @@ NSShouldRetainWithZone (NSObject *anObject, NSZone *requestedZone)
|
|||
return YES;
|
||||
#else
|
||||
return (!requestedZone || requestedZone == NSDefaultMallocZone()
|
||||
|| GSObjCZone(anObject) == requestedZone);
|
||||
|| [anObject zone] == requestedZone);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1986,7 +1988,13 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak));
|
|||
*/
|
||||
- (NSZone*) zone
|
||||
{
|
||||
return GSObjCZone(self);
|
||||
#if GS_WITH_GC
|
||||
/* MacOS-X 10.5 seems to return the default malloc zone if GC is enabled.
|
||||
*/
|
||||
return NSDefaultMallocZone();
|
||||
#else
|
||||
return (((obj)self)[-1]).zone;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -900,7 +900,7 @@ handle_printf_atsign (FILE *stream,
|
|||
#if GS_WITH_GC
|
||||
buf = NSAllocateCollectable(length, 0);
|
||||
#else
|
||||
buf = NSZoneMalloc(GSObjCZone(self), length);
|
||||
buf = NSZoneMalloc([self zone], length);
|
||||
#endif
|
||||
memcpy(buf, bytes, length);
|
||||
return [self initWithBytesNoCopy: buf
|
||||
|
@ -1023,7 +1023,7 @@ handle_printf_atsign (FILE *stream,
|
|||
|
||||
if (length > 0)
|
||||
{
|
||||
unichar *s = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*length);
|
||||
unichar *s = NSZoneMalloc([self zone], sizeof(unichar)*length);
|
||||
|
||||
[string getCharacters: s range: ((NSRange){0, length})];
|
||||
self = [self initWithCharactersNoCopy: s
|
||||
|
@ -1520,7 +1520,7 @@ handle_printf_atsign (FILE *stream,
|
|||
{
|
||||
unsigned len = [self length];
|
||||
unsigned otherLength = [aString length];
|
||||
NSZone *z = GSObjCZone(self);
|
||||
NSZone *z = [self zone];
|
||||
unichar *s = NSZoneMalloc(z, (len+otherLength)*sizeof(unichar));
|
||||
NSString *tmp;
|
||||
|
||||
|
@ -1688,7 +1688,7 @@ handle_printf_atsign (FILE *stream,
|
|||
|
||||
if (aRange.length == 0)
|
||||
return @"";
|
||||
buf = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*aRange.length);
|
||||
buf = NSZoneMalloc([self zone], sizeof(unichar)*aRange.length);
|
||||
[self getCharacters: buf range: aRange];
|
||||
ret = [[NSStringClass allocWithZone: NSDefaultMallocZone()]
|
||||
initWithCharactersNoCopy: buf length: aRange.length freeWhenDone: YES];
|
||||
|
@ -2418,7 +2418,7 @@ handle_printf_atsign (FILE *stream,
|
|||
if (whitespaceBitmapRep == NULL)
|
||||
setupWhitespace();
|
||||
|
||||
s = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*len);
|
||||
s = NSZoneMalloc([self zone], sizeof(unichar)*len);
|
||||
[self getCharacters: s range: ((NSRange){0, len})];
|
||||
while (count < len)
|
||||
{
|
||||
|
@ -2482,7 +2482,7 @@ handle_printf_atsign (FILE *stream,
|
|||
{
|
||||
return IMMUTABLE(self);
|
||||
}
|
||||
s = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*len);
|
||||
s = NSZoneMalloc([self zone], sizeof(unichar)*len);
|
||||
[self getCharacters: s range: ((NSRange){0, len})];
|
||||
for (count = start.location; count < len; count++)
|
||||
{
|
||||
|
@ -2519,7 +2519,7 @@ handle_printf_atsign (FILE *stream,
|
|||
{
|
||||
return IMMUTABLE(self);
|
||||
}
|
||||
s = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*len);
|
||||
s = NSZoneMalloc([self zone], sizeof(unichar)*len);
|
||||
[self getCharacters: s range: ((NSRange){0, len})];
|
||||
for (count = start.location; count < len; count++)
|
||||
{
|
||||
|
@ -4631,7 +4631,7 @@ static NSFileManager *fm = nil;
|
|||
#if GS_WITH_GC
|
||||
zone = GSAtomicMallocZone();
|
||||
#else
|
||||
zone = GSObjCZone(self);
|
||||
zone = [self zone];
|
||||
#endif
|
||||
|
||||
if (enc == NSUnicodeStringEncoding)
|
||||
|
|
|
@ -1115,7 +1115,7 @@ static unsigned urlAlign;
|
|||
if (_data != 0)
|
||||
{
|
||||
DESTROY(myData->absolute);
|
||||
NSZoneFree(GSObjCZone(self), _data);
|
||||
NSZoneFree([self zone], _data);
|
||||
_data = 0;
|
||||
}
|
||||
DESTROY(_urlString);
|
||||
|
|
|
@ -190,7 +190,7 @@ typedef struct
|
|||
o->_NSURLConnectionInternal
|
||||
= NSAllocateCollectable(sizeof(Internal), NSScannedOption);
|
||||
#else
|
||||
o->_NSURLConnectionInternal = NSZoneCalloc(GSObjCZone(self),
|
||||
o->_NSURLConnectionInternal = NSZoneCalloc([self zone],
|
||||
1, sizeof(Internal));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -442,7 +442,7 @@ static NSURLProtocol *placeholder = nil;
|
|||
{
|
||||
if (isa != abstractClass)
|
||||
{
|
||||
_NSURLProtocolInternal = NSZoneCalloc(GSObjCZone(self),
|
||||
_NSURLProtocolInternal = NSZoneCalloc([self zone],
|
||||
1, sizeof(Internal));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -391,7 +391,7 @@ static NSLock *placeholderLock;
|
|||
[coder encodeValueOfObjCType: @encode(unsigned) at: &size];
|
||||
[coder encodeArrayOfObjCType: @encode(signed char) count: size at: objctype];
|
||||
size = objc_sizeof_type(objctype);
|
||||
data = (void *)NSZoneMalloc(GSObjCZone(self), size);
|
||||
data = (void *)NSZoneMalloc([self zone], size);
|
||||
[self getValue: (void*)data];
|
||||
d = [NSMutableData new];
|
||||
[d serializeDataAt: data ofObjCType: objctype context: nil];
|
||||
|
@ -609,7 +609,7 @@ static NSLock *placeholderLock;
|
|||
{
|
||||
Class c = [abstractClass valueClassWithObjCType: type];
|
||||
|
||||
self = (id)NSAllocateObject(c, 0, GSObjCZone(self));
|
||||
self = (id)NSAllocateObject(c, 0, [self zone]);
|
||||
return [self initWithBytes: data objCType: type];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue