Oh no! A raw data allocation! If an exception occurs, congratulations, you just caused a memory leak!
I recommend
```std::vector<char*> dataBlock(packetSize + sizeof(packetSize);
std::memcpy(dataBlock.data(), &packetSize, sizeof(packetSize));
std::memcpy(dataBlock.data() + sizeof(packetSize), data, size);```
Then just remove the later delete[]