Draft: Cleanup the API after malloc() cannot fail
This does even more cleanups for functions that cannot really fail because of soft allocation failure is now impossible or the API is used only internally, so we can be more strict on the input parameters.
Closes #2938 (closed)
Edited by Ondřej Surý