Why doesn't free(p) set p to NULL?

前端 未结 9 1086
一向
一向 2020-12-10 12:33

Any reasons why this can not be standard behavior of free()?

multiple pointers pointing to the same object:

#include 
#i         


        
9条回答
  •  失恋的感觉
    2020-12-10 12:39

    In C, calling a function can never alter the value of the parameters you pass in, so if free(p) altered the value of p by setting it to NULL then this behaviour would be very non-standard indeed.

提交回复
热议问题