Fix compile time errors.

Errors discovered while testing on OpenBSD.
* malloc.h is obsolete.
* std::string::npos is a size_t so make sure it's comparison is too
(warning: comparison is always true due to limited range of data type)