Fix bug in object allocation when ARC is available

This commit is contained in:
Richard Frith-Macdonald 2018-01-04 09:08:36 +00:00
parent 562414810e
commit 4efa322ca2
2 changed files with 20 additions and 6 deletions

View file

@ -1,3 +1,14 @@
2018-01-04 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSObject.m: Fix bug with one path to object allocation
failing to record the object for memory debuggin purposes.
2018-01-03 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSURL.m:
Tweaks for OSX compatibility ... treat a missinp path in an http URL
as an empty string rather than as nil.
2018-01-02 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSFileManager.m:

View file

@ -767,10 +767,14 @@ callCXXConstructors(Class aClass, id anObject)
inline id
NSAllocateObject (Class aClass, NSUInteger extraBytes, NSZone *zone)
{
#ifdef OBJC_CAP_ARC
return class_createInstance(aClass, extraBytes);
#else
id new;
#ifdef OBJC_CAP_ARC
if ((new = class_createInstance(aClass, extraBytes)) != nil)
{
AADD(aClass, new);
}
#else
int size;
NSCAssert((!class_isMetaClass(aClass)), @"Bad class for new object");
@ -800,15 +804,14 @@ NSAllocateObject (Class aClass, NSUInteger extraBytes, NSZone *zone)
cxx_destruct = sel_registerName(".cxx_destruct");
}
callCXXConstructors(aClass, new);
#endif
return new;
#endif
}
inline void
NSDeallocateObject(id anObject)
{
Class aClass = object_getClass(anObject);
if ((anObject != nil) && !class_isMetaClass(aClass))
@ -1345,7 +1348,7 @@ static id gs_weak_load(id obj)
*/
- (void) dealloc
{
NSDeallocateObject (self);
NSDeallocateObject(self);
}
- (void) finalize