compat_rust.c 710 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* Copyright (c) 2017, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file rust_compat.c
  5. * \brief Rust FFI compatibility functions and helpers. This file is only built
  6. * if Rust is not used.
  7. **/
  8. #include "compat_rust.h"
  9. #include "util.h"
  10. /**
  11. * Free storage pointed to by <b>str</b>, and itself.
  12. */
  13. void
  14. rust_str_free(rust_str_t str)
  15. {
  16. char *s = (char *)str;
  17. tor_free(s);
  18. }
  19. /**
  20. * Return zero-terminated contained string.
  21. */
  22. const char *
  23. rust_str_get(const rust_str_t str)
  24. {
  25. return (const char *)str;
  26. }
  27. /* If we were using Rust, we'd say so on startup. */
  28. rust_str_t
  29. rust_welcome_string(void)
  30. {
  31. char *s = tor_malloc_zero(1);
  32. return (rust_str_t)s;
  33. }