This question was inspired by this answer.
I\'ve always been of the philosophy that the callee is never responsible when the caller does something stupid, like passi
In my opinion, it's the callee's responsibility to enforce its contract.
If the callee shouldn't accept NULL
, then it should assert
that.
Otherwise, the callee should be well behaved when it's handed a NULL
. That is, either it should functionally be a no-op, return an error code, or allocate its own memory, depending on the contract that you specified for it. It should do whatever seems to be the most sensible from the caller's perspective.
As the user of the API, I want to be able to continue using it without having the program crash; I want to be able to recover at the least or shut down gracefully at worst.