| 245 | |
| 246 | |
| 247 | void CPacket::PackPacket() |
| 248 | { |
| 249 | wxASSERT(!m_bSplitted); |
| 250 | |
| 251 | uLongf newsize = size + 300; |
| 252 | uint8_t* output = new uint8_t[newsize]; |
| 253 | |
| 254 | uint16 result = compress2(output, &newsize, pBuffer, size, Z_BEST_COMPRESSION); |
| 255 | |
| 256 | if (result != Z_OK || size <= newsize) { |
| 257 | delete[] output; |
| 258 | return; |
| 259 | } |
| 260 | |
| 261 | if (prot == OP_KADEMLIAHEADER) { |
| 262 | prot = OP_KADEMLIAPACKEDPROT; |
| 263 | } else { |
| 264 | prot = OP_PACKEDPROT; |
| 265 | } |
| 266 | |
| 267 | memcpy(pBuffer, output, newsize); |
| 268 | delete[] output; |
| 269 | m_bPacked = true; |
| 270 | |
| 271 | size = newsize; |
| 272 | } |
| 273 | |
| 274 | |
| 275 | bool CPacket::UnPackPacket(uint32 uMaxDecompressedSize) { |
no outgoing calls
no test coverage detected