throw std::runtime_error("No se puede reservar memoria");
f->mac = mac;
f->size = data.size();
- memcpy(f->frame, data.c_str(), data.size());
+ memcpy(f->frame, data.data(), data.size());
int res = msgsnd(que_id, f, mtu + sizeof(size_t), 0);
#ifdef DEBUG2
std::cout << "DevQue::transmit(msgtype/mac = " << f->mac << ", size = "
size_t size = data.size();
if (libtcp_send(tx_pool[mac], &size, sizeof(size_t)) != sizeof(size_t))
throw std::runtime_error("Error al enviar por el socket");
- if ((unsigned)libtcp_send(tx_pool[mac], data.c_str(), data.size()) != data.size())
+ if ((unsigned)libtcp_send(tx_pool[mac], data.data(), data.size()) != data.size())
throw std::runtime_error("Error al enviar por el socket");
#ifdef DEBUG2
std::cout << "DevTCP::transmit(mac = " << mac << ", size = "
/// Constructor a partir de un buffer
ResolvProtoRequest::ResolvProtoRequest(std::string buf)
{
- memcpy(&query_type, buf.c_str(), sizeof(uint8_t));
+ memcpy(&query_type, buf.data(), sizeof(uint8_t));
uint16_t size;
- memcpy(&size, buf.c_str() + sizeof(uint8_t), sizeof(uint16_t));
- name.assign(buf.c_str() + sizeof(uint8_t) + sizeof(uint16_t), size);
+ memcpy(&size, buf.data() + sizeof(uint8_t), sizeof(uint16_t));
+ name.assign(buf.data() + sizeof(uint8_t) + sizeof(uint16_t), size);
}
/// Convierte a un buffer
/// Constructor
ResolvProtoResponse::ResolvProtoResponse(std::string buf)
{
- memcpy(&ret, buf.c_str(), sizeof(uint8_t));
- memcpy(&ttl, buf.c_str() + sizeof(uint8_t), sizeof(uint32_t));
+ memcpy(&ret, buf.data(), sizeof(uint8_t));
+ memcpy(&ttl, buf.data() + sizeof(uint8_t), sizeof(uint32_t));
uint8_t count;
- memcpy(&count, buf.c_str() + sizeof(uint8_t) + sizeof(uint32_t),
+ memcpy(&count, buf.data() + sizeof(uint8_t) + sizeof(uint32_t),
sizeof(uint8_t));
ips.reserve(count);
for (uint8_t i = 0; i < count; ++i)
{
uint32_t ip;
- memcpy(&ip, buf.c_str() + 2 * sizeof(uint8_t)
+ memcpy(&ip, buf.data() + 2 * sizeof(uint8_t)
+ sizeof(uint32_t) * (i + 1), sizeof(uint32_t));
ips.push_back(ip);
}