Override the assignment operator for the Address class.
authorAdrian Bondrescu <adi.bondrescu@gmail.com>
Thu, 31 May 2012 23:31:31 +0000 (02:31 +0300)
committerAdrian Bondrescu <adi.bondrescu@gmail.com>
Thu, 31 May 2012 23:31:31 +0000 (02:31 +0300)
src/libswift/swift.h

index 2a9f68a..d44b882 100644 (file)
@@ -134,6 +134,15 @@ namespace swift {
        }
        uint32_t ipv4 () const { return ntohl(addr->dests[0].addr); }
        uint16_t port () const { return ntohs(addr->dests[0].port); }
+       Address& operator = (const Address& b) {
+               if (this != &b) {
+                       free(addr);
+                       clear();
+                       addr->dests[0].addr = b.addr->dests[0].addr;
+                       addr->dests[0].port = b.addr->dests[0].port;
+               }
+               return *this;
+       }
        bool operator == (const Address& b) const {
            return addr->count == b.addr->count &&
                addr->dests[0].port==b.addr->dests[0].port &&