mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
heck that NSAllocateObject() is given a class
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13585 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b0e0eb482d
commit
394ce82809
2 changed files with 19 additions and 12 deletions
|
@ -10,6 +10,8 @@
|
|||
that would just crash.
|
||||
In GSRegisterCurrentThread(), add code to handle the case where the
|
||||
NSThread class has not been initialised.
|
||||
* Source/NSObject.m: NSAllocateObject() raise exception if passed
|
||||
something other than a class to allocate an instance of.
|
||||
|
||||
2002-05-02 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
|
|
|
@ -437,10 +437,11 @@ GSFinalize(void* object, void* data)
|
|||
inline NSObject *
|
||||
NSAllocateObject(Class aClass, unsigned extraBytes, NSZone *zone)
|
||||
{
|
||||
id new = nil;
|
||||
int size = aClass->instance_size + extraBytes;
|
||||
id new;
|
||||
int size;
|
||||
|
||||
NSCAssert((CLS_ISCLASS(aClass)), @"Bad class for new object");
|
||||
size = aClass->instance_size + extraBytes;
|
||||
if (zone == GSAtomicMallocZone())
|
||||
{
|
||||
new = NSZoneMalloc(zone, size);
|
||||
|
@ -522,14 +523,16 @@ NSAllocateObject (Class aClass, unsigned extraBytes, NSZone *zone)
|
|||
#ifndef NDEBUG
|
||||
extern void GSDebugAllocationAdd(Class c, id o);
|
||||
#endif
|
||||
id new = nil;
|
||||
int size = aClass->instance_size + extraBytes + sizeof(struct obj_layout);
|
||||
if (CLS_ISCLASS (aClass))
|
||||
id new;
|
||||
int size;
|
||||
|
||||
NSCAssert((CLS_ISCLASS(aClass)), @"Bad class for new object");
|
||||
size = aClass->instance_size + extraBytes + sizeof(struct obj_layout);
|
||||
if (zone == 0)
|
||||
{
|
||||
if (zone == 0)
|
||||
zone = NSDefaultMallocZone();
|
||||
new = NSZoneMalloc(zone, size);
|
||||
zone = NSDefaultMallocZone();
|
||||
}
|
||||
new = NSZoneMalloc(zone, size);
|
||||
if (new != nil)
|
||||
{
|
||||
memset (new, 0, size);
|
||||
|
@ -589,10 +592,12 @@ GSObjCZone(NSObject *object)
|
|||
inline NSObject *
|
||||
NSAllocateObject (Class aClass, unsigned extraBytes, NSZone *zone)
|
||||
{
|
||||
id new = nil;
|
||||
int size = aClass->instance_size + extraBytes;
|
||||
if (CLS_ISCLASS (aClass))
|
||||
new = NSZoneMalloc (zone, size);
|
||||
id new;
|
||||
int size;
|
||||
|
||||
NSCAssert((CLS_ISCLASS(aClass)), @"Bad class for new object");
|
||||
size = aClass->instance_size + extraBytes;
|
||||
new = NSZoneMalloc (zone, size);
|
||||
if (new != nil)
|
||||
{
|
||||
memset (new, 0, size);
|
||||
|
|
Loading…
Reference in a new issue