Moving to std::string in options

This commit is contained in:
Ian Barber
2012-02-14 23:10:06 +00:00
parent 770f84331f
commit b5d3373905
8 changed files with 22 additions and 18 deletions

View File

@@ -30,7 +30,6 @@ zmq::options_t::options_t () :
rcvhwm (1000),
affinity (0),
identity_size (0),
last_endpoint_size(0),
rate (100),
recovery_ivl (10000),
multicast_hops (1),
@@ -387,12 +386,13 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
return 0;
case ZMQ_LAST_ENDPOINT:
if (*optvallen_ < last_endpoint_size) {
// don't allow string which cannot contain the entire message
if (*optvallen_ < last_endpoint.size() + 1) {
errno = EINVAL;
return -1;
}
memcpy (optval_, last_endpoint, last_endpoint_size);
*optvallen_ = last_endpoint_size;
memcpy (optval_, last_endpoint.c_str(), last_endpoint.size()+1);
*optvallen_ = last_endpoint.size()+1;
return 0;
}