mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
gnrc_priority_queue: updated coding style.
This commit is contained in:
parent
c925c5b437
commit
e5d8dde920
@ -24,8 +24,9 @@
|
||||
#define NET_GNRC_PRIORITY_PKTQUEUE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <priority_queue.h>
|
||||
#include <net/gnrc/pkt.h>
|
||||
|
||||
#include "priority_queue.h"
|
||||
#include "net/gnrc/pkt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -83,6 +84,7 @@ static inline void gnrc_priority_pktqueue_node_init(gnrc_priority_pktqueue_node_
|
||||
static inline void gnrc_priority_pktqueue_init(gnrc_priority_pktqueue_t *queue)
|
||||
{
|
||||
gnrc_priority_pktqueue_t qn = PRIORITY_PKTQUEUE_INIT;
|
||||
|
||||
*queue = qn;
|
||||
}
|
||||
|
||||
@ -100,7 +102,7 @@ uint32_t gnrc_priority_pktqueue_length(gnrc_priority_pktqueue_t *queue);
|
||||
*
|
||||
* @param[out] queue the gnrc priority packet queue, must not be NULL
|
||||
*/
|
||||
void gnrc_priority_pktqueue_flush(gnrc_priority_pktqueue_t* queue);
|
||||
void gnrc_priority_pktqueue_flush(gnrc_priority_pktqueue_t *queue);
|
||||
|
||||
/**
|
||||
* @brief Get first element and remove it from @p queue
|
||||
@ -109,7 +111,7 @@ void gnrc_priority_pktqueue_flush(gnrc_priority_pktqueue_t* queue);
|
||||
*
|
||||
* @return the old head
|
||||
*/
|
||||
gnrc_pktsnip_t* gnrc_priority_pktqueue_pop(gnrc_priority_pktqueue_t* queue);
|
||||
gnrc_pktsnip_t *gnrc_priority_pktqueue_pop(gnrc_priority_pktqueue_t *queue);
|
||||
|
||||
/**
|
||||
* @brief Get first element from @p queue without removing
|
||||
@ -118,7 +120,7 @@ gnrc_pktsnip_t* gnrc_priority_pktqueue_pop(gnrc_priority_pktqueue_t* queue);
|
||||
*
|
||||
* @return the head of @p queue
|
||||
*/
|
||||
gnrc_pktsnip_t* gnrc_priority_pktqueue_head(gnrc_priority_pktqueue_t* queue);
|
||||
gnrc_pktsnip_t *gnrc_priority_pktqueue_head(gnrc_priority_pktqueue_t *queue);
|
||||
|
||||
/**
|
||||
* @brief add @p node into @p queue based on its priority
|
||||
@ -126,7 +128,7 @@ gnrc_pktsnip_t* gnrc_priority_pktqueue_head(gnrc_priority_pktqueue_t* queue);
|
||||
* @param[in,out] queue the gnrc priority packet queue, must not be NULL
|
||||
* @param[in] node the node to add.
|
||||
*/
|
||||
void gnrc_priority_pktqueue_push(gnrc_priority_pktqueue_t* queue,
|
||||
void gnrc_priority_pktqueue_push(gnrc_priority_pktqueue_t *queue,
|
||||
gnrc_priority_pktqueue_node_t *node);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "net/gnrc/pktbuf.h"
|
||||
#include <net/gnrc/priority_pktqueue.h>
|
||||
#include "net/gnrc/priority_pktqueue.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@ -33,51 +33,50 @@ static inline void _free_node(gnrc_priority_pktqueue_node_t *node)
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
gnrc_pktsnip_t* gnrc_priority_pktqueue_pop(gnrc_priority_pktqueue_t* queue)
|
||||
gnrc_pktsnip_t *gnrc_priority_pktqueue_pop(gnrc_priority_pktqueue_t *queue)
|
||||
{
|
||||
if(!queue || (gnrc_priority_pktqueue_length(queue) == 0)){
|
||||
if (!queue || (gnrc_priority_pktqueue_length(queue) == 0)) {
|
||||
return NULL;
|
||||
}
|
||||
priority_queue_node_t *head = priority_queue_remove_head(queue);
|
||||
gnrc_pktsnip_t* pkt = (gnrc_pktsnip_t*) head->data;
|
||||
gnrc_pktsnip_t *pkt = (gnrc_pktsnip_t *) head->data;
|
||||
_free_node((gnrc_priority_pktqueue_node_t *)head);
|
||||
return pkt;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
gnrc_pktsnip_t* gnrc_priority_pktqueue_head(gnrc_priority_pktqueue_t* queue)
|
||||
gnrc_pktsnip_t *gnrc_priority_pktqueue_head(gnrc_priority_pktqueue_t *queue)
|
||||
{
|
||||
if(!queue || (gnrc_priority_pktqueue_length(queue) == 0)){
|
||||
if (!queue || (gnrc_priority_pktqueue_length(queue) == 0)) {
|
||||
return NULL;
|
||||
}
|
||||
return (gnrc_pktsnip_t *)queue->first->data;
|
||||
}
|
||||
/******************************************************************************/
|
||||
|
||||
void gnrc_priority_pktqueue_push(gnrc_priority_pktqueue_t* queue,
|
||||
gnrc_priority_pktqueue_node_t *node)
|
||||
void gnrc_priority_pktqueue_push(gnrc_priority_pktqueue_t *queue,
|
||||
gnrc_priority_pktqueue_node_t *node)
|
||||
{
|
||||
assert(queue != NULL);
|
||||
assert(node != NULL);
|
||||
assert(node->pkt != NULL);
|
||||
assert(sizeof(unsigned int) == sizeof(gnrc_pktsnip_t*));
|
||||
assert(sizeof(unsigned int) == sizeof(gnrc_pktsnip_t *));
|
||||
|
||||
priority_queue_add(queue, (priority_queue_node_t *)node);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
void gnrc_priority_pktqueue_flush(gnrc_priority_pktqueue_t* queue)
|
||||
void gnrc_priority_pktqueue_flush(gnrc_priority_pktqueue_t *queue)
|
||||
{
|
||||
assert(queue != NULL);
|
||||
|
||||
if(gnrc_priority_pktqueue_length(queue) == 0){
|
||||
if (gnrc_priority_pktqueue_length(queue) == 0) {
|
||||
return;
|
||||
}
|
||||
gnrc_priority_pktqueue_node_t* node;
|
||||
while( (node = (gnrc_priority_pktqueue_node_t *)priority_queue_remove_head(queue)) )
|
||||
{
|
||||
gnrc_priority_pktqueue_node_t *node;
|
||||
while ((node = (gnrc_priority_pktqueue_node_t *)priority_queue_remove_head(queue))) {
|
||||
gnrc_pktbuf_release(node->pkt);
|
||||
_free_node(node);
|
||||
}
|
||||
@ -90,13 +89,13 @@ uint32_t gnrc_priority_pktqueue_length(gnrc_priority_pktqueue_t *queue)
|
||||
|
||||
uint32_t length = 0;
|
||||
priority_queue_node_t *node = queue->first;
|
||||
if(!node){
|
||||
if (!node) {
|
||||
return length;
|
||||
}
|
||||
|
||||
length ++;
|
||||
while(node->next!=NULL){
|
||||
length ++;
|
||||
length++;
|
||||
while (node->next != NULL) {
|
||||
length++;
|
||||
node = node->next;
|
||||
}
|
||||
return length;
|
||||
|
Loading…
Reference in New Issue
Block a user