Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions crates/types/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,9 @@ impl Clone for String {

impl Drop for String {
fn drop(&mut self) {
// There's no way to know if the pointer we get from Neovim
// points to some `malloc`ed memory or to a static/borrowed string.
//
// TODO: we're leaking memory here if the pointer points to allocated
// memory.
if !self.as_ptr().is_null() {
unsafe { libc::free(self.as_ptr() as *mut ffi::c_void) }
}
}
}

Expand Down
8 changes: 0 additions & 8 deletions crates/types/src/string_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,6 @@ impl fmt::Write for StringBuilder {
}
}

impl Drop for StringBuilder {
fn drop(&mut self) {
if !self.inner.as_ptr().is_null() {
unsafe { libc::free(self.inner.as_ptr() as *mut ffi::c_void) }
}
}
}

#[cold]
#[inline(never)]
fn unable_to_alloc_memory() {
Expand Down
Loading