• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
memory deallocation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: memory deallocation
      • From: Scott Ribe <email@hidden>
    • Re: memory deallocation
      • From: Dave Carrigan <email@hidden>
    • Re: memory deallocation
      • From: Andrew Farmer <email@hidden>
  • Prev by Date: Re: IB Plugin help
  • Next by Date: Re: memory deallocation
  • Previous by thread: Cursor Invisible when NSTextView is not editable
  • Next by thread: Re: memory deallocation
  • Index(es):
    • Date
    • Thread