[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Move hex_str to binascii.c



commit 0a9d8dcf2b0de62402efacc0fa4bc9a29109a6c0
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Wed Jun 27 16:21:55 2018 -0400

    Move hex_str to binascii.c
---
 src/common/util.c           | 15 ---------------
 src/common/util.h           |  2 --
 src/lib/encoding/binascii.c | 15 +++++++++++++++
 src/lib/encoding/binascii.h |  2 ++
 4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/common/util.c b/src/common/util.c
index 574b017ba..28efa4a04 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -225,21 +225,6 @@ add_laplace_noise(int64_t signal_, double random_, double delta_f,
  * String manipulation
  * ===== */
 
-/** Return a pointer to a NUL-terminated hexadecimal string encoding
- * the first <b>fromlen</b> bytes of <b>from</b>. (fromlen must be \<= 32.) The
- * result does not need to be deallocated, but repeated calls to
- * hex_str will trash old results.
- */
-const char *
-hex_str(const char *from, size_t fromlen)
-{
-  static char buf[65];
-  if (fromlen>(sizeof(buf)-1)/2)
-    fromlen = (sizeof(buf)-1)/2;
-  base16_encode(buf,sizeof(buf),from,fromlen);
-  return buf;
-}
-
 /** Return true if <b>string</b> is a valid 'key=[value]' string.
  *  "value" is optional, to indicate the empty string. Log at logging
  *  <b>severity</b> if something ugly happens. */
diff --git a/src/common/util.h b/src/common/util.h
index f9018ff88..7547b8708 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -71,8 +71,6 @@ int64_t clamp_double_to_int64(double number);
 
 /* String manipulation */
 
-const char *hex_str(const char *from, size_t fromlen) ATTR_NONNULL((1));
-
 int string_is_key_value(int severity, const char *string);
 
 char *tor_escape_str_for_pt_args(const char *string,
diff --git a/src/lib/encoding/binascii.c b/src/lib/encoding/binascii.c
index 554b95016..df9bb4a81 100644
--- a/src/lib/encoding/binascii.c
+++ b/src/lib/encoding/binascii.c
@@ -25,6 +25,21 @@
 #include <string.h>
 #include <stdlib.h>
 
+/** Return a pointer to a NUL-terminated hexadecimal string encoding
+ * the first <b>fromlen</b> bytes of <b>from</b>. (fromlen must be \<= 32.) The
+ * result does not need to be deallocated, but repeated calls to
+ * hex_str will trash old results.
+ */
+const char *
+hex_str(const char *from, size_t fromlen)
+{
+  static char buf[65];
+  if (fromlen>(sizeof(buf)-1)/2)
+    fromlen = (sizeof(buf)-1)/2;
+  base16_encode(buf,sizeof(buf),from,fromlen);
+  return buf;
+}
+
 /* Return the base32 encoded size in bytes using the source length srclen.
  *
  * (WATCH OUT: This API counts the terminating NUL byte, but
diff --git a/src/lib/encoding/binascii.h b/src/lib/encoding/binascii.h
index 04310f4ed..67f9eb0e8 100644
--- a/src/lib/encoding/binascii.h
+++ b/src/lib/encoding/binascii.h
@@ -12,6 +12,8 @@
 #include "lib/testsupport/testsupport.h"
 #include "lib/cc/torint.h"
 
+const char *hex_str(const char *from, size_t fromlen);
+
 /** @{ */
 /** These macros don't check for overflow.  Use them only for constant inputs
  * (like array declarations).  The *_LEN macros are the raw encoding lengths



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits