Answer to Question #3363 in Action Script | Flash | Flex | ColdFusion for suman majumder

Question #3363
What is dangling pointer?please explain with a suitable example!
1
Expert's answer
2011-07-06T08:51:57-0400
Dangling pointers are pointers that do not point to a valid object of theappropriate type, like you deleted what it points at.
Dangling pointers arise when an object is deleted or deallocated, without modifying
the value of the pointer, so that the pointer still points to the memory location of
the deallocated memory. As the system may reallocate the previously freed memory to
another process, if the original program then dereferences the dangling pointer,
unpredictable behavior may result, as the memory may now contain completely
different data.

A straightforward example is shown below:

{
char *dp = NULL;
/* ... */
{
char c;
dp = &c;
}
/* c falls out of scope */
/* dp is now a dangling pointer */
}

A solution to the above is to assign NULL to cp immediately before the inner block
is exited. Another solution would be to somehow guarantee cp is not used again
without further initialisation.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
08.07.11, 12:10

You are welcome!

suman majumder
07.07.11, 20:36

Thank you very very much sir!!!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS