added malloc sanity check, fixed wall warnings on windows