Make all API functions accept NULL as input.

Doing so enormously simplifies error handling; you no longer have to check
for memory allocation errors in a chain of sds function calls, only after
the last call.