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
|
#define NET_GNRC_PRIORITY_PKTQUEUE_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <priority_queue.h>
|
|
||||||
#include <net/gnrc/pkt.h>
|
#include "priority_queue.h"
|
||||||
|
#include "net/gnrc/pkt.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
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)
|
static inline void gnrc_priority_pktqueue_init(gnrc_priority_pktqueue_t *queue)
|
||||||
{
|
{
|
||||||
gnrc_priority_pktqueue_t qn = PRIORITY_PKTQUEUE_INIT;
|
gnrc_priority_pktqueue_t qn = PRIORITY_PKTQUEUE_INIT;
|
||||||
|
|
||||||
*queue = qn;
|
*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
|
* @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
|
* @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
|
* @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
|
* @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
|
* @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
|
* @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,out] queue the gnrc priority packet queue, must not be NULL
|
||||||
* @param[in] node the node to add.
|
* @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);
|
gnrc_priority_pktqueue_node_t *node);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "net/gnrc/pktbuf.h"
|
#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;
|
return NULL;
|
||||||
}
|
}
|
||||||
priority_queue_node_t *head = priority_queue_remove_head(queue);
|
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);
|
_free_node((gnrc_priority_pktqueue_node_t *)head);
|
||||||
return pkt;
|
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 NULL;
|
||||||
}
|
}
|
||||||
return (gnrc_pktsnip_t *)queue->first->data;
|
return (gnrc_pktsnip_t *)queue->first->data;
|
||||||
}
|
}
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
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)
|
gnrc_priority_pktqueue_node_t *node)
|
||||||
{
|
{
|
||||||
assert(queue != NULL);
|
assert(queue != NULL);
|
||||||
assert(node != NULL);
|
assert(node != NULL);
|
||||||
assert(node->pkt != 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);
|
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);
|
assert(queue != NULL);
|
||||||
|
|
||||||
if(gnrc_priority_pktqueue_length(queue) == 0){
|
if (gnrc_priority_pktqueue_length(queue) == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gnrc_priority_pktqueue_node_t* node;
|
gnrc_priority_pktqueue_node_t *node;
|
||||||
while( (node = (gnrc_priority_pktqueue_node_t *)priority_queue_remove_head(queue)) )
|
while ((node = (gnrc_priority_pktqueue_node_t *)priority_queue_remove_head(queue))) {
|
||||||
{
|
|
||||||
gnrc_pktbuf_release(node->pkt);
|
gnrc_pktbuf_release(node->pkt);
|
||||||
_free_node(node);
|
_free_node(node);
|
||||||
}
|
}
|
||||||
@ -90,13 +89,13 @@ uint32_t gnrc_priority_pktqueue_length(gnrc_priority_pktqueue_t *queue)
|
|||||||
|
|
||||||
uint32_t length = 0;
|
uint32_t length = 0;
|
||||||
priority_queue_node_t *node = queue->first;
|
priority_queue_node_t *node = queue->first;
|
||||||
if(!node){
|
if (!node) {
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
length ++;
|
length++;
|
||||||
while(node->next!=NULL){
|
while (node->next != NULL) {
|
||||||
length ++;
|
length++;
|
||||||
node = node->next;
|
node = node->next;
|
||||||
}
|
}
|
||||||
return length;
|
return length;
|
||||||
|
Loading…
Reference in New Issue
Block a user