Skip to content

Commit 1324f2d

Browse files
committed
capi: explicitly call drop() for calling free() via Box
1 parent 19b05d8 commit 1324f2d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

regex-capi/src/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ ffi_fn! {
5454

5555
ffi_fn! {
5656
fn rure_error_free(err: *mut Error) {
57-
unsafe { Box::from_raw(err); }
57+
unsafe { drop(Box::from_raw(err)); }
5858
}
5959
}
6060

regex-capi/src/rure.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ ffi_fn! {
151151

152152
ffi_fn! {
153153
fn rure_free(re: *const Regex) {
154-
unsafe { Box::from_raw(re as *mut Regex); }
154+
unsafe { drop(Box::from_raw(re as *mut Regex)); }
155155
}
156156
}
157157

@@ -260,7 +260,7 @@ ffi_fn! {
260260
while let Some(ptr) = it.name_ptrs.pop() {
261261
drop(CString::from_raw(ptr));
262262
}
263-
Box::from_raw(it);
263+
drop(Box::from_raw(it));
264264
}
265265
}
266266
}
@@ -316,7 +316,7 @@ ffi_fn! {
316316

317317
ffi_fn! {
318318
fn rure_iter_free(it: *mut Iter) {
319-
unsafe { Box::from_raw(it); }
319+
unsafe { drop(Box::from_raw(it)); }
320320
}
321321
}
322322

@@ -407,7 +407,7 @@ ffi_fn! {
407407

408408
ffi_fn! {
409409
fn rure_captures_free(captures: *const Captures) {
410-
unsafe { Box::from_raw(captures as *mut Captures); }
410+
unsafe { drop(Box::from_raw(captures as *mut Captures)); }
411411
}
412412
}
413413

@@ -447,7 +447,7 @@ ffi_fn! {
447447

448448
ffi_fn! {
449449
fn rure_options_free(options: *mut Options) {
450-
unsafe { Box::from_raw(options); }
450+
unsafe { drop(Box::from_raw(options)); }
451451
}
452452
}
453453

@@ -527,7 +527,7 @@ ffi_fn! {
527527

528528
ffi_fn! {
529529
fn rure_set_free(re: *const RegexSet) {
530-
unsafe { Box::from_raw(re as *mut RegexSet); }
530+
unsafe { drop(Box::from_raw(re as *mut RegexSet)); }
531531
}
532532
}
533533

0 commit comments

Comments
 (0)