+/*
+ * This constructs a SockAddr that points at one specific sub-address
+ * of a parent SockAddr. The returned SockAddr does not own all its
+ * own memory: it points into the old one's data structures, so it
+ * MUST NOT be used after the old one is freed, and it MUST NOT be
+ * passed to sk_addr_free. (The latter is why it's returned by value
+ * rather than dynamically allocated - that should clue in anyone
+ * writing a call to it that something is weird about it.)
+ */
+static struct SockAddr_tag sk_extractaddr_tmp(
+ SockAddr addr, const SockAddrStep *step)
+{
+ struct SockAddr_tag toret;
+ toret = *addr; /* structure copy */
+ toret.refcount = 1;
+
+ if (addr->superfamily == IP) {
+#ifndef NO_IPV6
+ toret.ais = step->ai;
+#else
+ assert(SOCKADDR_FAMILY(addr, *step) == AF_INET);
+ toret.addresses += step->curraddr;
+#endif
+ }
+
+ return toret;
+}
+