memory deallocation
memory deallocation
- Subject: memory deallocation
- From: Daniel Luis dos Santos <email@hidden>
- Date: Sat, 4 Apr 2009 22:35:47 +0100
Hello,
From what I know so far, memory allocated using the malloc() family
of functions is freed using the free() function. Literal values such
as :
char *aString = "some text";
are automatic values and are deallocated by the compiler automatically.
When I free some pointer that was allocated as in the example
declaration above I get a warning that a non page-aligned, non
allocated pointer is being freed. Then in practical terms, what does a
literal value such as a #define that is used to initialize pointers
such as the one above serves for ?
If for example I have a group of string #defines that are used in log
messages, that means that I will have to malloc space for them the
sprintf them to it, so I can be sure that I don't get that warning
when deallocating the log messages.
when you pass as pointer to bytes (like a void*) to cocoa (for example
NSData), what does it do ? It copies the bytes or just copies the
pointer ? If I pass &aString to it that means that at the end of the
scope it will be deallocated, and NSData will have a dangling pointer ?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden