db_lmdb: factor the MDB_val setup code

It makes the code simpler, avoids possible copy/paste errors
(wrong sizeof, etc), and generally unclutters the calling code.