vendredi 21 juin 2019

How can I free malloc

Free malloc

ubuntu c++

for (pcpp::RawPacketVector::VectorIterator iter = PacketVector.begin(); iter != PacketVector.end(); iter++)
        {
      pcpp::Packet parsedPacket(*iter);
      pcpp::PayloadLayer* payloadLayer = parsedPacket.getLayerOfType<pcpp::PayloadLayer>();
      string data(payloadLayer->getPayload(),payloadLayer->getPayload()+payloadLayer->getPayloadLen());
      const unsigned char * Payload=(unsigned char *)malloc(sizeof(unsigned char)*data.length());
      strcpy((char *)Payload,data.c_str());
      this->data_packet.push_back(Payload);

problem memory valgrind

Aucun commentaire:

Enregistrer un commentaire