-- | Read a reference count for a given address.
readRefctIO :: VSpace -> Address -> IO Int
readRefctIO vc addr =
    alloca $ \ pAddr ->
    withRdOnlyTxn vc $ \ txn ->
    poke pAddr addr >>
    let vAddr = MDB_val { mv_data = castPtr pAddr
                        , mv_size = fromIntegral (sizeOf addr) }
    in
    mdb_get' txn (vcache_db_refcts vc) vAddr >>= \ mbData ->
    maybe (return 0) readRefctBytes mbData
readRefctIO :: VSpace -> Address -> IO Int
readRefctIO vc addr =
    alloca $ \ pAddr ->
    withRdOnlyTxn vc $ \ txn ->
    poke pAddr addr >>
    let vAddr = MDB_val { mv_data = castPtr pAddr
                        , mv_size = fromIntegral (sizeOf addr) }
    in
    mdb_get' txn (vcache_db_refcts vc) vAddr >>= \ mbData ->
    maybe (return 0) readRefctBytes mbData
readRefctIO vc addr =
    alloca $ \ pAddr ->
    withRdOnlyTxn vc $ \ txn ->
    poke pAddr addr >>
    let vAddr = MDB_val { mv_data = castPtr pAddr
                        , mv_size = fromIntegral (sizeOf addr) }
    in
    mdb_get' txn (vcache_db_refcts vc) vAddr >>= \ mbData ->
    maybe (return 0) readRefctBytes mbData