diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/include.am | 2 | ||||
-rw-r--r-- | src/common/rust_types.c | 55 | ||||
-rw-r--r-- | src/common/rust_types.h | 22 |
3 files changed, 0 insertions, 79 deletions
diff --git a/src/common/include.am b/src/common/include.am index 7ce84e17c5..cd5eea3404 100644 --- a/src/common/include.am +++ b/src/common/include.am @@ -94,7 +94,6 @@ LIBOR_A_SRC = \ src/common/util_bug.c \ src/common/util_format.c \ src/common/util_process.c \ - src/common/rust_types.c \ src/common/sandbox.c \ src/common/storagedir.c \ src/common/workqueue.c \ @@ -180,7 +179,6 @@ COMMONHEADERS = \ src/common/procmon.h \ src/common/pubsub.h \ src/common/sandbox.h \ - src/common/rust_types.h \ src/common/storagedir.h \ src/common/testsupport.h \ src/common/timers.h \ diff --git a/src/common/rust_types.c b/src/common/rust_types.c deleted file mode 100644 index 1b6dd3990e..0000000000 --- a/src/common/rust_types.c +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (c) 2017, The Tor Project, Inc. */ -/* See LICENSE for licensing information */ - -/** - * \file rust_types.c - * \brief This file is used for handling types returned from Rust to C. - **/ - -#include "or.h" -#include "rust_types.h" - -#ifdef HAVE_RUST - -void free_rust_str(char *ret); - -/* Because Rust strings can only be freed from Rust, we first copy the string's - * contents to a c pointer, and then free the Rust string. - * This function can be extended to return a success/error value if needed. - */ -void -move_rust_str_to_c_and_free(rust_str_ref_t src, char **dest) -{ - if (!src) { - log_warn(LD_BUG, "Received a null pointer from protover rust."); - return; - } - - if (!dest) { - log_warn(LD_BUG, "Received a null pointer from caller to rust. " - "This results in a memory leak due to not freeing the rust " - "string that was meant to be copied.."); - return; - } - - *dest = tor_strdup(src); - free_rust_str(src); - return; -} - -#else - -/* When Rust is not enabled, this function should never be used. Log a warning - * in the case that it is ever called when Rust is not enabled. - */ -void -move_rust_str_to_c_and_free(rust_str_ref_t src, char **dest) -{ - (void) src; - (void) dest; - log_warn(LD_BUG, "Received a call to free a Rust string when we are " - " not running with Rust enabled."); - return; -} -#endif /* defined(HAVE_RUST) */ - diff --git a/src/common/rust_types.h b/src/common/rust_types.h deleted file mode 100644 index b6d807e656..0000000000 --- a/src/common/rust_types.h +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright (c) 2017, The Tor Project, Inc. */ -/* See LICENSE for licensing information */ - -/** - * \file rust_types.h - * \brief Headers for rust_types.c - **/ - -#include "or.h" - -#ifndef TOR_RUST_TYPES_H -#define TOR_RUST_TYPES_H - -/* This type is used to clearly mark strings that have been allocated in Rust, - * and therefore strictly need to use the free_rust_str method to free. - */ -typedef char *rust_str_ref_t; - -void move_rust_str_to_c_and_free(rust_str_ref_t src, char **dest); - -#endif - |