Codechange: remove public access to the next pointer in Packet

This commit is contained in:
Rubidium
2021-04-20 18:50:46 +02:00
committed by rubidium42
parent f71fb0f54a
commit 3abefdf561
4 changed files with 38 additions and 35 deletions

View File

@@ -62,6 +62,32 @@ Packet::~Packet()
free(this->buffer);
}
/**
* Add the given Packet to the end of the queue of packets.
* @param queue The pointer to the begin of the queue.
* @param packet The packet to append to the queue.
*/
/* static */ void Packet::AddToQueue(Packet **queue, Packet *packet)
{
while (*queue != nullptr) queue = &(*queue)->next;
*queue = packet;
}
/**
* Pop the packet from the begin of the queue and set the
* begin of the queue to the second element in the queue.
* @param queue The pointer to the begin of the queue.
* @return The Packet that used to be a the begin of the queue.
*/
/* static */ Packet *Packet::PopFromQueue(Packet **queue)
{
Packet *p = *queue;
*queue = p->next;
p->next = nullptr;
return p;
}
/**
* Writes the packet size from the raw packet from packet->size
*/