|
|
|
@ -18,6 +18,7 @@
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#include <inttypes.h> |
|
|
|
|
#include <assert.h> |
|
|
|
|
|
|
|
|
|
#include "priority_queue.h" |
|
|
|
|
|
|
|
|
@ -55,6 +56,8 @@ void priority_queue_add(priority_queue_t *root, priority_queue_node_t *new_obj)
|
|
|
|
|
priority_queue_node_t *node = (priority_queue_node_t *) root; |
|
|
|
|
|
|
|
|
|
while (node->next != NULL) { |
|
|
|
|
/* not trying to add the same node twice */ |
|
|
|
|
assert(node->next != new_obj); |
|
|
|
|
if (node->next->priority > new_obj->priority) { |
|
|
|
|
new_obj->next = node->next; |
|
|
|
|
node->next = new_obj; |
|
|
|
|