deal with OOM handling in one place and prior to returning result

This commit removes 4 (four!) duplicates of C++ OOM handling. And
introduces one helper for that.

Other change is that malloc doesn't have to check tc_new_mode anymore
until it _actually_ deals with OOM condition. Which shaves off couple
instructions from fast-path.
2 files changed