TCHDB: Fixup 32bit overflows
TCHDB: Fixup 32bit overflows

This is an attempt to fix 32bit overflows in TCHDB in order to squash
ARAKOON-373.

Based on 8fd64af678c613c8f035ecf8a3276c6cf0aea370.

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

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