Handle incoming 0's and NULL's.

Wmem framework used to handle those for us, but now we must do it ourselves.
Add extern-C blocks so that it compiles under C++