Simple answer: because you might be freeing an expression, e.g. free(find_named_object("foo"))
.
In more detail: The free
function takes a void*
parameter, which is the address of the memory to free. This doesn't confer to the function any knowledge of the original variable that supplied the address (or, for that matter, whether there even exists a variable). Just setting the parameter passed in to NULL would do nothing either, since it's just a local copy of the address.