Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 31, 2008, 12:05:12 AM (16 years ago)
Author:
rgrieder
Message:

Properly took care of network::packet::Packet destruction. It depends very much whether the the data was allocated by ENet or by ourselves.

File:
1 edited

Legend:

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

    r2062 r2070  
    286286  //copy over the header
    287287  *GAMESTATE_HEADER(ndata) = *HEADER;
    288   //delete old (compressed data)
    289   delete[] data_;
     288
     289  if (this->bDataENetAllocated_){
     290    // Memory was allocated by ENet. --> We let it be since enet_packet_destroy will
     291    // deallocated it anyway. So data and packet stay together.
     292    this->bDataENetAllocated_ = false;
     293  }
     294  else{
     295    // We allocated the memory in the first place (unlikely). So we destroy the old data
     296    // and overwrite it with the new decompressed data.
     297    delete[] this->data_;
     298  }
     299
    290300  //set new pointers
    291301  data_ = ndata;
Note: See TracChangeset for help on using the changeset viewer.