S
saurabh29789
Is it safe to move(increment/decrement/re-position) the pointer to
whom the dynamic memory was allocated to??
I mean :
{
int *p, *q;
p = (int*)malloc(10*sizeof(int));
q=p;
p = p+5;
..
..
Some Code
..
..
p = q;
free(p);
}
In this code, will the memory be safely freed ?
Some one told me that if I move the pointer to point to some other
(valid) location and then even if I return it back to the previous
location (starting address of the dynamically allocated memory), then
it might lose some information that it stores after the dynamic
allocation is done and, thus, the memory blocks might not be freed.
Is it so?
whom the dynamic memory was allocated to??
I mean :
{
int *p, *q;
p = (int*)malloc(10*sizeof(int));
q=p;
p = p+5;
..
..
Some Code
..
..
p = q;
free(p);
}
In this code, will the memory be safely freed ?
Some one told me that if I move the pointer to point to some other
(valid) location and then even if I return it back to the previous
location (starting address of the dynamically allocated memory), then
it might lose some information that it stores after the dynamic
allocation is done and, thus, the memory blocks might not be freed.
Is it so?