Skip to content

Commit

Permalink
capi: explicitly call drop() for calling free() via Box
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Jul 14, 2022
1 parent 19b05d8 commit 1324f2d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion regex-capi/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ ffi_fn! {

ffi_fn! {
fn rure_error_free(err: *mut Error) {
unsafe { Box::from_raw(err); }
unsafe { drop(Box::from_raw(err)); }
}
}

Expand Down
12 changes: 6 additions & 6 deletions regex-capi/src/rure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ ffi_fn! {

ffi_fn! {
fn rure_free(re: *const Regex) {
unsafe { Box::from_raw(re as *mut Regex); }
unsafe { drop(Box::from_raw(re as *mut Regex)); }
}
}

Expand Down Expand Up @@ -260,7 +260,7 @@ ffi_fn! {
while let Some(ptr) = it.name_ptrs.pop() {
drop(CString::from_raw(ptr));
}
Box::from_raw(it);
drop(Box::from_raw(it));
}
}
}
Expand Down Expand Up @@ -316,7 +316,7 @@ ffi_fn! {

ffi_fn! {
fn rure_iter_free(it: *mut Iter) {
unsafe { Box::from_raw(it); }
unsafe { drop(Box::from_raw(it)); }
}
}

Expand Down Expand Up @@ -407,7 +407,7 @@ ffi_fn! {

ffi_fn! {
fn rure_captures_free(captures: *const Captures) {
unsafe { Box::from_raw(captures as *mut Captures); }
unsafe { drop(Box::from_raw(captures as *mut Captures)); }
}
}

Expand Down Expand Up @@ -447,7 +447,7 @@ ffi_fn! {

ffi_fn! {
fn rure_options_free(options: *mut Options) {
unsafe { Box::from_raw(options); }
unsafe { drop(Box::from_raw(options)); }
}
}

Expand Down Expand Up @@ -527,7 +527,7 @@ ffi_fn! {

ffi_fn! {
fn rure_set_free(re: *const RegexSet) {
unsafe { Box::from_raw(re as *mut RegexSet); }
unsafe { drop(Box::from_raw(re as *mut RegexSet)); }
}
}

Expand Down

0 comments on commit 1324f2d

Please sign in to comment.