Free memory on writebatch index and avoid unnecessary clones (#786)

master
J 2 years ago committed by GitHub
parent b539412366
commit 8cf89962f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/transactions/transaction.rs

@ -852,8 +852,8 @@ impl<'db, DB> Transaction<'db, DB> {
let wi = ffi::rocksdb_transaction_get_writebatch_wi(self.inner);
let mut len: usize = 0;
let ptr = ffi::rocksdb_writebatch_wi_data(wi, &mut len as _);
let data = std::slice::from_raw_parts(ptr, len).to_owned();
let writebatch = ffi::rocksdb_writebatch_create_from(data.as_ptr(), data.len());
let writebatch = ffi::rocksdb_writebatch_create_from(ptr, len);
ffi::rocksdb_free(wi as *mut c_void);
WriteBatchWithTransaction { inner: writebatch }
}
}

Loading…
Cancel
Save