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

+3

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

Aid

2 Answers

New Answer

+6

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.

+3

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