gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnustep-cvs] r31629 - in /libs/back/trunk: ./ Source/cairo/ Source/


From: Nicola Pero
Subject: Re: [Gnustep-cvs] r31629 - in /libs/back/trunk: ./ Source/cairo/ Source/gsc/ Source/win32/ Source/winlib/ Source/x11/
Date: Sat, 20 Nov 2010 14:13:32 +0000


objc_malloc() and friends are GCC-runtime specific. They are not supported by other runtimes. If there is a reason for avoiding malloc(), using either NSZoneMalloc() or NSAllocateCollectable() should be the preferred indirection.

Using malloc() is usually wrong as it can't work with garbage collection. ;-)

I'd replace 'usually' with 'sometimes' there. malloc() is absolutely fine (and should be preferred) as long as it is not used to store object pointers and it is matched with free() in - finalize. I'd also add that it CAN be used with object pointers as long as CFRetain() is called on them (rather than -retain) in Apple- land, so we should support this in GNUstep. Of course, if you're storing object pointers then NSMutableArray is probably a better bet.

Using objc_malloc() for something that is stored in an ivar and contains non-object types is almost always wrong - you're burdening the GC for no benefit.

Yes - it could be inefficient - every case need to be examined and understood :-)

But if there is any doubt, using objc_malloc() is certainly safer.

Thanks



reply via email to

[Prev in Thread] Current Thread [Next in Thread]