Re: Allocating memory in Cocoa
Re: Allocating memory in Cocoa
- Subject: Re: Allocating memory in Cocoa
- From: Charlton Wilbur <email@hidden>
- Date: Sat, 25 Dec 2004 13:42:22 -0500
On Dec 25, 2004, at 12:54 PM, Peter Karlsson wrote:
What is the right way of allocating memory in Cocoa?
Well, the simplest way is to use +alloc and -init. What problem are
you trying to solve that those can't handle?
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");
}
That will allocate memory, but it doesn't fit the general Cocoa and
Objective-C idioms. My inclination would be to call that the *wrong*
way of going about it, but there are reasons you might want to do it.
Without knowing why you're allocating memory, or what problem you have
that +alloc/-init don't solve, I can't comment on whether that approach
is actually the right thing to do.
Charlton
--
Charlton Wilbur
email@hidden
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden