Add tests for pqueue
Reorder the tests in all_tests.sh to be in alphabetical order.
Change-Id: Idc6df6ab4a25709312a6f58635061bb643582c70
Reviewed-on: https://boringssl-review.googlesource.com/1680
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/ssl/pqueue/pqueue.c b/ssl/pqueue/pqueue.c
index 4c68cb1..4c94355 100644
--- a/ssl/pqueue/pqueue.c
+++ b/ssl/pqueue/pqueue.c
@@ -111,7 +111,7 @@
pitem *curr;
for (curr = pq->items; curr; curr = curr->next) {
- if (memcmp(curr->priority, prio64be, 8) == 0) {
+ if (memcmp(curr->priority, prio64be, sizeof(curr->priority)) == 0) {
return curr;
}
}
@@ -130,9 +130,9 @@
return count;
}
-pitem *pqueue_iterator(pqueue_s *pq) { return pq->items; }
+piterator pqueue_iterator(pqueue_s *pq) { return pq->items; }
-pitem *pqueue_next(pitem **item) {
+pitem *pqueue_next(piterator *item) {
pitem *ret;
if (item == NULL || *item == NULL) {
@@ -156,9 +156,9 @@
for (curr = NULL, next = pq->items; next != NULL;
curr = next, next = next->next) {
/* we can compare 64-bit value in big-endian encoding with memcmp. */
- int cmp = memcmp(next->priority, item->priority, 8);
- if (cmp > 0) /* next > item */
- {
+ int cmp = memcmp(next->priority, item->priority, sizeof(item->priority));
+ if (cmp > 0) {
+ /* next > item */
item->next = next;
if (curr == NULL) {
@@ -168,8 +168,10 @@
}
return item;
- } else if (cmp == 0) /* duplicates not allowed */
+ } else if (cmp == 0) {
+ /* duplicates not allowed */
return NULL;
+ }
}
item->next = NULL;