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

javascript - THREE.js reposition vertices for RingGeometry -

javascript - I need to update the text of a paragraph by inline edit -

assembly - What is the addressing mode for ld, add, and rjmp instructions? -