- Timestamp:
- Sep 9, 2008, 1:43:47 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/packet/Packet.cc
r1741 r1749 92 92 93 93 Packet::~Packet(){ 94 if(enetPacket_) 94 if(enetPacket_){ 95 assert(enetPacket_->freeCallback==0); 95 96 enet_packet_destroy(enetPacket_); 97 } 96 98 if(data_) 97 99 delete[] data_; … … 109 111 } 110 112 enetPacket_ = enet_packet_create(getData(), getSize(), getFlags()); 111 //enetPacket_->freeCallback = &Packet::deletePacket;112 enetPacket_->freeCallback = &blub;113 enetPacket_->freeCallback = &Packet::deletePacket; 114 // enetPacket_->freeCallback = &blub; 113 115 packetMap_[enetPacket_] = this; 114 116 } … … 127 129 } 128 130 #endif 129 network::Host::addPacket( enetPacket_, clientID_);131 ENetPacket *temp = enetPacket_; 130 132 enetPacket_ = 0; // otherwise we have a double free because enet already handles the deallocation of the packet 133 network::Host::addPacket( temp, clientID_); 131 134 return true; 132 135 } … … 169 172 void Packet::deletePacket(ENetPacket *packet){ 170 173 assert(packetMap_[packet]); 174 assert(packetMap_[packet]->enetPacket_==0); 171 175 delete packetMap_[packet]; 172 176 }
Note: See TracChangeset
for help on using the changeset viewer.