Yes calling free will free the memory. Its not the pointer that get freed but the memory that the pointer points to that is freed.
Thank you! I'm guessing the information on how much memory was allocated is stored elsewhere, so that when 'free' is called, it knows how much to free up? – Russbear Jun 1 at 18:01 Yes, that is correct.
– Richard Schneider Jun 1 at 20:34.
You must pass to free() the value obtained from malloc(). Int *x = malloc(42 * sizeof *x); int *p = &x0; free(p); /* ok, same as free x; x and p have the same value */ Edit: another example int *x = malloc(42 * sizeof *x); for (k = 0; k.
1 the value is the key here and what OP doesn't seem to understand. – R.. May 31 at 0:12.
Then the answer is "no" -- you must pass free() the exact pointer which you got back from malloc(). Trying to free() an internal pointer, or a pointer to memory which was not allocated by malloc(), memory corruption or a crash are likely to occur.
I think you misunderstood OP's question. – R.. May 31 at 0:12.
I've just written a function that returns a pointer to a block of memory allocated by malloc. If I call free() on the returned pointer, will this free the memory? I tried reading up on this, but I can't find anything that says whether you can call a different pointer pointing to the same location and whether that will free all the memory or not.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.