Re: NSMakePoint and such - what about memory allocation?
Re: NSMakePoint and such - what about memory allocation?
- Subject: Re: NSMakePoint and such - what about memory allocation?
- From: Nicko van Someren <email@hidden>
- Date: Fri, 21 May 2004 04:12:48 +0100
On 21 May 2004, at 3:17, Christoffer Lerno wrote:
Having programmed java almost exclusively for many years now, memory
allocation questions in obj-c sometimes leave me a little confused.
If I use NSMakePoint in this manner:
NSPoint a=NSMakePoint(10,10);
Am I not:
a) first creating an empty, static bound, NSPoint.
b) then allocate memory and create yet another NSPoint with the
NSMakePoint command.
The static NSPoint will disappear when it runs out of scope, but what
about the point created with NSMakePoint, isn't that one dynamically
created and as such needs to be explicitly deallocated? I don't really
see any code actually deallocating these kinds of structs though, so
I'm suspecting I don't need to, but if so - why?
An easy mistake to make but no, this is not a problem.
NSPoint is a structure, the good, old fashioned C kind. Functions can
return structures in Objective-C and from an implementation point of
view they actually get passes a pointer to the place the result will be
used and it gets filled in by the "return" statement.
Nicko
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.