X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fio%2Fraw_socket.cxx;h=7fe2c6884cb61ca49dd07915a74a7bcce7e93bc2;hb=b7654c181dc8d52875365b170bc3092e8e51d68f;hp=8bcae9852d8fbf47126833c28ceb0c8008437747;hpb=50e226a1467d53d9bcb2987d0b6cfb58beb66c9c;p=simgear.git diff --git a/simgear/io/raw_socket.cxx b/simgear/io/raw_socket.cxx index 8bcae985..7fe2c688 100644 --- a/simgear/io/raw_socket.cxx +++ b/simgear/io/raw_socket.cxx @@ -67,6 +67,30 @@ IPAddress::IPAddress ( const char* host, int port ) set ( host, port ) ; } +IPAddress::IPAddress( const IPAddress& other ) : + addr(NULL) +{ + if (other.addr) { + addr = (struct sockaddr_in*) malloc(sizeof(struct sockaddr_in)); + memcpy(addr, other.addr, sizeof(struct sockaddr_in)); + } +} + +const IPAddress& IPAddress::operator=(const IPAddress& other) +{ + if (addr) { + free(addr); + addr = NULL; + } + + if (other.addr) { + addr = (struct sockaddr_in*) malloc(sizeof(struct sockaddr_in)); + memcpy(addr, other.addr, sizeof(struct sockaddr_in)); + } + + return *this; +} + void IPAddress::set ( const char* host, int port ) { addr = (struct sockaddr_in*) malloc(sizeof(struct sockaddr_in));