On 20 Nov 2010, at 12:57, Nicola Pero wrote: > On 20 Nov 2010, at 12:44, David Chisnall wrote: > >> 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. David _______________________________________________ Gnustep-dev mailing list [email protected] http://lists.gnu.org/mailman/listinfo/gnustep-dev
