diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-05-19 08:47:18 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-05-19 08:47:18 -0400 |
commit | 69ef94820b29500d93a8f2775764b8b96284bacb (patch) | |
tree | 1337215f718c30da8cc8d1529c5a3a890e488316 /src/common/compat_rust.c | |
parent | 92d335b3dcd7b302d8a07c105f9fe8a98848cad3 (diff) | |
parent | 70c067102b7d2576fa456d2872bb41abf559dff6 (diff) | |
download | tor-69ef94820b29500d93a8f2775764b8b96284bacb.tar.gz tor-69ef94820b29500d93a8f2775764b8b96284bacb.zip |
Merge branch 'add_rust_squashed'
Diffstat (limited to 'src/common/compat_rust.c')
-rw-r--r-- | src/common/compat_rust.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/common/compat_rust.c b/src/common/compat_rust.c new file mode 100644 index 0000000000..366fd4037b --- /dev/null +++ b/src/common/compat_rust.c @@ -0,0 +1,39 @@ +/* Copyright (c) 2017, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +/** + * \file rust_compat.c + * \brief Rust FFI compatibility functions and helpers. This file is only built + * if Rust is not used. + **/ + +#include "compat_rust.h" +#include "util.h" + +/** + * Free storage pointed to by <b>str</b>, and itself. + */ +void +rust_str_free(rust_str_t str) +{ + char *s = (char *)str; + tor_free(s); +} + +/** + * Return zero-terminated contained string. + */ +const char * +rust_str_get(const rust_str_t str) +{ + return (const char *)str; +} + +/* If we were using Rust, we'd say so on startup. */ +rust_str_t +rust_welcome_string(void) +{ + char *s = tor_malloc_zero(1); + return (rust_str_t)s; +} + |