Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • when we malloc something..where actuly this memory gona reseve.?? in stack ..? in heap..? in Ram..?? Commented Aug 10, 2011 at 7:20
  • @Mr. 32 That's implementation specific but in most systems malloc allocates heap memory. Commented Aug 10, 2011 at 7:23
  • Both the stack and heap on the RAM. Malloc should reserve on heap space, so it isn't deleted at the end of the function. Commented Aug 10, 2011 at 7:25
  • 1
    Some people advocate using #define free(x) do { free(x); x = NULL; } while(0) to avoid forgetting to set the pointer to NULL when you're done with it. In my experience the pointer frequently falls out of scope right after I free it, so I don't usually bother. Commented Aug 10, 2011 at 7:26
  • @David Heffernan i got it all....thnk u... one more thing in any case m i able to access those memory which i have freed.? Commented Aug 10, 2011 at 7:55