mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Remove the zone pointer from objects. Now we always query the zones to find the relevant pointer. Zones are still supported, but we now optimise for the case where they are not used.
To disable zone support completely, NSAllocateObject() should ignore the zone and NSDeallocateObject() should skip the zone lookup. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33610 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
018fab87bd
commit
40456f7787
1 changed files with 3 additions and 6 deletions
|
@ -409,7 +409,6 @@ static inline NSLock *GSAllocationLockForObject(id p)
|
|||
* (before the start) in each object.
|
||||
*/
|
||||
typedef struct obj_layout_unpadded {
|
||||
NSZone *zone;
|
||||
NSUInteger retained;
|
||||
} unp;
|
||||
#define UNP sizeof(unp)
|
||||
|
@ -420,7 +419,6 @@ typedef struct obj_layout_unpadded {
|
|||
* structure correct.
|
||||
*/
|
||||
struct obj_layout {
|
||||
NSZone *zone;
|
||||
NSUInteger retained;
|
||||
char padding[ALIGN - ((UNP % ALIGN) ? (UNP % ALIGN) : ALIGN)];
|
||||
};
|
||||
|
@ -770,7 +768,7 @@ GSObjCZone(NSObject *object)
|
|||
GSOnceFLog(@"GSObjCZone() is deprecated ... use -zone instead");
|
||||
if (object_getClass(object) == NSConstantStringClass)
|
||||
return NSDefaultMallocZone();
|
||||
return ((obj)object)[-1].zone;
|
||||
return NSZoneFromPointer(object);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -818,7 +816,6 @@ NSAllocateObject (Class aClass, NSUInteger extraBytes, NSZone *zone)
|
|||
if (new != nil)
|
||||
{
|
||||
memset (new, 0, size);
|
||||
((obj)new)->zone = zone;
|
||||
new = (id)&((obj)new)[1];
|
||||
object_setClass(new, aClass);
|
||||
AADD(aClass, new);
|
||||
|
@ -861,7 +858,7 @@ NSDeallocateObject(id anObject)
|
|||
if ((anObject != nil) && !class_isMetaClass(aClass))
|
||||
{
|
||||
obj o = &((obj)anObject)[-1];
|
||||
NSZone *z = o->zone;
|
||||
NSZone *z = NSZoneFromPointer(o);
|
||||
|
||||
/* Call the default finalizer to handle C++ destructors.
|
||||
*/
|
||||
|
@ -2160,7 +2157,7 @@ static id gs_weak_load(id obj)
|
|||
*/
|
||||
return NSDefaultMallocZone();
|
||||
#else
|
||||
return (((obj)self)[-1]).zone;
|
||||
return NSZoneFromPointer(self);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue