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

Php operator `break` doesn't stop while -

ubuntu - Bash Script to Check That Files Are Being Created -

vim: Search & replace -