mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 05:20:00 +02:00
Fix NLPacket::create
This commit is contained in:
parent
f90f3a05be
commit
01f1a6e2b9
1 changed files with 10 additions and 4 deletions
|
@ -29,11 +29,17 @@ qint64 NLPacket::localHeaderSize() const {
|
|||
return localHeaderSize(_type);
|
||||
}
|
||||
|
||||
std::unique_ptr<NLPacket> NLPacket::create(PacketType::Value type, int64_t size) {
|
||||
if (size > maxPayloadSize(type)) {
|
||||
return std::unique_ptr<NLPacket>();
|
||||
std::unique_ptr<NLPacket> NLPacket::create(PacketType::Value type, qint64 size) {
|
||||
auto maxPayload = maxPayloadSize(type);
|
||||
if (size == -1) {
|
||||
// default size of -1, means biggest packet possible
|
||||
size = maxPayload;
|
||||
}
|
||||
|
||||
|
||||
// Fail with invalid size
|
||||
Q_ASSERT(size >= 0 || size < maxPayload);
|
||||
|
||||
// allocate memory
|
||||
return std::unique_ptr<NLPacket>(new NLPacket(type, size));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue