I do not understand how to free memory? | Sololearn: Learn to code for FREE!


I do not understand how to free memory?

if the location that a pointer (p) points to in the heap memory is freed using another pointer (q) , what is the pointer pointing to deallocated memory called? realloc , free

c++ c

4/11/2021 1:05:32 PM


2 Answers

New Answer


In c, you'd use the free function. free corresponds with c's malloc or calloc functions. In c++, you'd use the delete keyword. delete corresponds with c++'s "new" keyword. A pointer holding the address of a freed block of memory doesn't have a special name that I'm aware of. I would set it to NULL as soon as possible, though. NULL clearly indicates that it doesn't point to an allocated block of memory. Any other value often means something is accessible so you're more at risk for a segmentation fault, memory access violation, or other buggy behaviour by maintaining a non-NULL pointer to a freed block of memory.


I dont think, there is an official name for it. But it is often called "dangling Pointer".