Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1749 for code


Ignore:
Timestamp:
Sep 9, 2008, 1:43:47 PM (16 years ago)
Author:
scheusso
Message:

one memory problem less (enetpacket freeCallback should work find now)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/network/packet/Packet.cc

    r1741 r1749  
    9292
    9393Packet::~Packet(){
    94   if(enetPacket_)
     94  if(enetPacket_){
     95    assert(enetPacket_->freeCallback==0);
    9596    enet_packet_destroy(enetPacket_);
     97  }
    9698  if(data_)
    9799    delete[] data_;
     
    109111    }
    110112    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;
    113115    packetMap_[enetPacket_] = this;
    114116  }
     
    127129  }
    128130#endif
    129   network::Host::addPacket( enetPacket_, clientID_);
     131  ENetPacket *temp = enetPacket_;
    130132  enetPacket_ = 0; // otherwise we have a double free because enet already handles the deallocation of the packet
     133  network::Host::addPacket( temp, clientID_);
    131134  return true;
    132135}
     
    169172void Packet::deletePacket(ENetPacket *packet){
    170173  assert(packetMap_[packet]);
     174  assert(packetMap_[packet]->enetPacket_==0);
    171175  delete packetMap_[packet];
    172176}
Note: See TracChangeset for help on using the changeset viewer.