From a7e2b6a8b2fbceb2caa56b2d72db56af459d4a93 Mon Sep 17 00:00:00 2001 From: Douglas Creager Date: Tue, 23 Feb 2021 09:39:39 -0500 Subject: [PATCH] Remove allocations_stubs These were used to provide the `ts_record_*` functions regardless of whether the `allocation-tracking` feature is enabled. The allocation tracking code is now implemented entirely in the `lib` crate, and only when the feature is enabled, and so these stubs are no longer needed. --- cli/src/allocations_stubs.rs | 40 ------------------------------------ cli/src/lib.rs | 3 --- 2 files changed, 43 deletions(-) delete mode 100644 cli/src/allocations_stubs.rs diff --git a/cli/src/allocations_stubs.rs b/cli/src/allocations_stubs.rs deleted file mode 100644 index b4b6dde1..00000000 --- a/cli/src/allocations_stubs.rs +++ /dev/null @@ -1,40 +0,0 @@ -// In all dev builds, the tree-sitter library is built with the `allocation-tracking` -// feature enabled. This causes the library to link against a set of externally -// defined C functions like `ts_record_malloc` and `ts_record_free`. In tests, these -// are defined to actually keep track of outstanding allocations. But when not running -// tests, the symbols still need to be defined. This file provides pass-through -// implementations of all of these functions. - -use std::os::raw::c_void; - -extern "C" { - fn malloc(size: usize) -> *mut c_void; - fn calloc(count: usize, size: usize) -> *mut c_void; - fn realloc(ptr: *mut c_void, size: usize) -> *mut c_void; - fn free(ptr: *mut c_void); -} - -#[no_mangle] -unsafe extern "C" fn ts_record_malloc(size: usize) -> *const c_void { - malloc(size) -} - -#[no_mangle] -unsafe extern "C" fn ts_record_calloc(count: usize, size: usize) -> *const c_void { - calloc(count, size) -} - -#[no_mangle] -unsafe extern "C" fn ts_record_realloc(ptr: *mut c_void, size: usize) -> *const c_void { - realloc(ptr, size) -} - -#[no_mangle] -unsafe extern "C" fn ts_record_free(ptr: *mut c_void) { - free(ptr) -} - -#[no_mangle] -extern "C" fn ts_toggle_allocation_recording(_: bool) -> bool { - false -} diff --git a/cli/src/lib.rs b/cli/src/lib.rs index 5b491574..e00323b7 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -16,6 +16,3 @@ pub mod web_ui; #[cfg(test)] mod tests; - -#[cfg(not(test))] -mod allocations_stubs;