c - Usage of free() function -



c - Usage of free() function -

suppose have linked list node head pointer , passed head other function test(node *np)

what happens if free np within function test head might or might not pointing node?

according c standard using free improper pointer undefined behavior:

7.22.3.3 free function

....

the free function causes space pointed ptr deallocated, is, made available farther allocation. if ptr null pointer, no action occurs. otherwise, if argument not match pointer before returned memory management function, or if space has been deallocated phone call free or realloc, behavior undefined.

c pointers

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -