From 8cf89962f8d205b6d3ca55fed6356502c230d522 Mon Sep 17 00:00:00 2001 From: J Date: Mon, 5 Jun 2023 03:41:11 -0400 Subject: [PATCH] Free memory on writebatch index and avoid unnecessary clones (#786) --- src/transactions/transaction.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/transactions/transaction.rs b/src/transactions/transaction.rs index 39b2b06..089e1ad 100644 --- a/src/transactions/transaction.rs +++ b/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 } } }