[fix] safe_walloc uses size_t
[fix] Check function returns, fix memory leaks