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

[tor-commits] [tor/master] Add a tor_addr_port_copy() function.



commit 44da9206701a2b157474f94ccf64996dce192924
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Thu Jul 16 13:51:35 2020 -0400

    Add a tor_addr_port_copy() function.
---
 src/lib/net/address.c | 12 ++++++++++++
 src/lib/net/address.h |  1 +
 2 files changed, 13 insertions(+)

diff --git a/src/lib/net/address.c b/src/lib/net/address.c
index cf4af423a7..5a32533610 100644
--- a/src/lib/net/address.c
+++ b/src/lib/net/address.c
@@ -2114,6 +2114,18 @@ tor_addr_port_eq(const tor_addr_port_t *a,
   return tor_addr_eq(&a->addr, &b->addr) && a->port == b->port;
 }
 
+/**
+ * Copy a tor_addr_port_t from @a source to @a dest.
+ **/
+void
+tor_addr_port_copy(tor_addr_port_t *dest,
+                   const tor_addr_port_t *source)
+{
+  tor_assert(dest);
+  tor_assert(source);
+  memcpy(dest, source, sizeof(tor_addr_port_t));
+}
+
 /** Return true if <b>string</b> represents a valid IPv4 adddress in
  * 'a.b.c.d' form.
  */
diff --git a/src/lib/net/address.h b/src/lib/net/address.h
index e19b446e8d..bc8ec7744f 100644
--- a/src/lib/net/address.h
+++ b/src/lib/net/address.h
@@ -394,6 +394,7 @@ get_interface_address_list(int severity, int include_internal)
 tor_addr_port_t *tor_addr_port_new(const tor_addr_t *addr, uint16_t port);
 int tor_addr_port_eq(const tor_addr_port_t *a,
                      const tor_addr_port_t *b);
+void tor_addr_port_copy(tor_addr_port_t *dest, const tor_addr_port_t *source);
 
 int string_is_valid_dest(const char *string);
 int string_is_valid_nonrfc_hostname(const char *string);



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