Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak when calling get_writebatch and avoid unnecessary clones #786

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/transactions/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
Expand Down