aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-10-27 12:49:51 -0400
committerNick Mathewson <nickm@torproject.org>2017-10-27 12:49:51 -0400
commit1e66ab363a561c3b419269eca8f7e92346718075 (patch)
tree6eb9afe98ccef3ad0e71d0b0edab2f016650c5e2 /src
parentd64297e4e0c08c26502078cb7ee2815f9d2f8049 (diff)
downloadtor-1e66ab363a561c3b419269eca8f7e92346718075.tar.gz
tor-1e66ab363a561c3b419269eca8f7e92346718075.zip
[rust] Add "unsafe" to the testing-mode tor_malloc_ wrapper.
This change lets us remove the allow(unused_unsafe) directive from allocate_and_copy_string().
Diffstat (limited to 'src')
-rw-r--r--src/rust/tor_allocate/tor_allocate.rs8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/rust/tor_allocate/tor_allocate.rs b/src/rust/tor_allocate/tor_allocate.rs
index 8a6fabe9cb..359df1cd7a 100644
--- a/src/rust/tor_allocate/tor_allocate.rs
+++ b/src/rust/tor_allocate/tor_allocate.rs
@@ -12,9 +12,9 @@ extern "C" {
// Defined only for tests, used for testing purposes, so that we don't need
// to link to tor C files. Uses the system allocator
#[cfg(test)]
-extern "C" fn tor_malloc_(size: usize) -> *mut c_void {
+unsafe extern "C" fn tor_malloc_(size: usize) -> *mut c_void {
use libc::malloc;
- unsafe { malloc(size) }
+ malloc(size)
}
/// Allocate memory using tor_malloc_ and copy an existing string into the
@@ -28,10 +28,6 @@ extern "C" fn tor_malloc_(size: usize) -> *mut c_void {
///
/// A `*mut c_char` that should be freed by tor_free in C
///
-/// Allow unused unsafe as at compile-time, we get warnings that unsafe is not
-/// needed even though this calls tor_malloc in C.
-///
-#[allow(unused_unsafe)]
pub fn allocate_and_copy_string(src: &String) -> *mut c_char {
let bytes: &[u8] = src.as_bytes();