*
*/
+#include "cryptlib.h"
+#include <openssl/bn.h>
#include "pqueue.h"
-#include "crypto.h"
typedef struct _pqueue
{
} pqueue_s;
pitem *
-pitem_new(unsigned long long priority, void *data)
+pitem_new(PQ_64BIT priority, void *data)
{
pitem *item = (pitem *) OPENSSL_malloc(sizeof(pitem));
if (item == NULL) return NULL;
- item->priority = priority;
+ pq_64bit_init(&(item->priority));
+ pq_64bit_assign(&item->priority, &priority);
+
item->data = data;
item->next = NULL;
pitem_free(pitem *item)
{
if (item == NULL) return;
-
+
+ pq_64bit_free(&(item->priority));
OPENSSL_free(item);
}
next != NULL;
curr = next, next = next->next)
{
- if (item->priority < next->priority)
+ if (pq_64bit_gt(&(next->priority), &(item->priority)))
{
item->next = next;
return item;
}
/* duplicates not allowed */
- if (item->priority == next->priority)
+ if (pq_64bit_eq(&(item->priority), &(next->priority)))
return NULL;
}
}
pitem *
-pqueue_find(pqueue_s *pq, unsigned long long priority)
+pqueue_find(pqueue_s *pq, PQ_64BIT priority)
{
pitem *next, *prev = NULL;
pitem *found = NULL;
for ( next = pq->items; next->next != NULL;
prev = next, next = next->next)
{
- if ( next->priority == priority)
+ if ( pq_64bit_eq(&(next->priority), &priority))
{
found = next;
break;
}
/* check the one last node */
- if ( next->priority == priority)
+ if ( pq_64bit_eq(&(next->priority), &priority))
found = next;
if ( ! found)
return found;
}
+#if PQ_64BIT_IS_INTEGER
void
pqueue_print(pqueue_s *pq)
{
while(item != NULL)
{
- printf("item\t%lld\n", item->priority);
+ printf("item\t" PQ_64BIT_PRINT "\n", item->priority);
item = item->next;
}
}
+#endif
pitem *
pqueue_iterator(pqueue_s *pq)