Add truncation/overflow checks & reporting
Add truncation/overflow checks & reporting

This is based on ed97cf64d89979ead63c662d42d19f7d0bfaee09, but somewhat
less agressive (no `abort` calls).

Original idea by Bastiaan Stougie <bstougie@b-virtual.org>.

Incubaid/tokyocabinet,Incubaid/tokyocabinet,Incubaid/tokyocabinet,Incubaid/tokyocabinet,Incubaid/tokyocabinet