Release the OCaml runtime lock around `tcbdbget`

In order to allow for multi-threaded read access to the database, the OCaml
runtime lock should be released when entering TokyoCabinet. In turn, this
requires some string copying.

This change releases the runtime lock, and adds the required copying, while
avoiding `malloc` calls for keys smaller than 1kB.