FROM : Prachi Gauriar
DATE : Sat Dec 25 22:08:57 2004
On Dec 25, 2004, at 11:54 AM, Peter Karlsson wrote:
> Dear list!
>
> What is the right way of allocating memory in Cocoa?
>
> I'm using this code at the moment.
>
> // allocate 100000 bytes for memory1_ptr
> if((memory1_ptr = malloc(100000)) == NULL)
> {
> printf("malloc memory1_ptr failed\n");
> }
There's also void NSZoneMalloc
void *NSZoneMalloc(NSZone *zone, unsigned int size)
It's like malloc, but allocates from the specified zone, which seems
more appropriate for objects allocated/copied using
+allocWithZone:/copyWithZone:. There's also NSZoneCalloc, NSZoneFree,
and NSZoneRealloc.
<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/
ObjC_classic/Functions/FoundationFunctions.html#//apple_ref/doc/uid/
20000055/BCIHIEBB>
-Prachi
DATE : Sat Dec 25 22:08:57 2004
On Dec 25, 2004, at 11:54 AM, Peter Karlsson wrote:
> Dear list!
>
> What is the right way of allocating memory in Cocoa?
>
> I'm using this code at the moment.
>
> // allocate 100000 bytes for memory1_ptr
> if((memory1_ptr = malloc(100000)) == NULL)
> {
> printf("malloc memory1_ptr failed\n");
> }
There's also void NSZoneMalloc
void *NSZoneMalloc(NSZone *zone, unsigned int size)
It's like malloc, but allocates from the specified zone, which seems
more appropriate for objects allocated/copied using
+allocWithZone:/copyWithZone:. There's also NSZoneCalloc, NSZoneFree,
and NSZoneRealloc.
<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/
ObjC_classic/Functions/FoundationFunctions.html#//apple_ref/doc/uid/
20000055/BCIHIEBB>
-Prachi
| Related mails | Author | Date |
|---|---|---|
| Peter Karlsson | Dec 25, 18:54 | |
| Charlton Wilbur | Dec 25, 19:42 | |
| Prachi Gauriar | Dec 25, 22:08 | |
| Finlay Dobbie | Dec 25, 23:43 | |
| Sherm Pendley | Dec 26, 17:42 |






Cocoa mail archive

