]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Move hex_str to binascii.c
authorNick Mathewson <nickm@torproject.org>
Wed, 27 Jun 2018 20:21:55 +0000 (16:21 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 27 Jun 2018 20:59:56 +0000 (16:59 -0400)
src/common/util.c
src/common/util.h
src/lib/encoding/binascii.c
src/lib/encoding/binascii.h

index 574b017ba80eb9bd4fb4090b13a0fbee79fbb62a..28efa4a042b0d7ac76d94fabc0ae08653979a50a 100644 (file)
@@ -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. */
index f9018ff880a118f1020406ad03919a975dd2b194..7547b8708a34bdcc54b97260979a84e85138ecb6 100644 (file)
@@ -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,
index 554b95016b2d0e22e113c8de4c86e8247ce8f899..df9bb4a8134e80edda91ad2b1ef0ae208ed80c1b 100644 (file)
 #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
index 04310f4ed9ca03f56f921d4209f5838518f0df03..67f9eb0e870e4264426b2eb54b12c463a3448267 100644 (file)
@@ -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