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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to