aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/openssl/ssl/pqueue.c
diff options
context:
space:
mode:
authordeshevoy <deshevoy@yandex-team.ru>2022-02-10 16:46:56 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:56 +0300
commite988f30484abe5fdeedcc7a5d3c226c01a21800c (patch)
tree0a217b173aabb57b7e51f8a169989b1a3e0309fe /contrib/libs/openssl/ssl/pqueue.c
parent33ee501c05d3f24036ae89766a858930ae66c548 (diff)
downloadydb-e988f30484abe5fdeedcc7a5d3c226c01a21800c.tar.gz
Restoring authorship annotation for <deshevoy@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/openssl/ssl/pqueue.c')
-rw-r--r--contrib/libs/openssl/ssl/pqueue.c314
1 files changed, 157 insertions, 157 deletions
diff --git a/contrib/libs/openssl/ssl/pqueue.c b/contrib/libs/openssl/ssl/pqueue.c
index 758440217d..053ace7a96 100644
--- a/contrib/libs/openssl/ssl/pqueue.c
+++ b/contrib/libs/openssl/ssl/pqueue.c
@@ -1,158 +1,158 @@
-/*
- * Copyright 2005-2018 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the OpenSSL license (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
+/*
+ * Copyright 2005-2018 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the OpenSSL license (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
#include "ssl_local.h"
-#include <openssl/bn.h>
-
-struct pqueue_st {
- pitem *items;
- int count;
-};
-
-pitem *pitem_new(unsigned char *prio64be, void *data)
-{
- pitem *item = OPENSSL_malloc(sizeof(*item));
-
- if (item == NULL) {
- SSLerr(SSL_F_PITEM_NEW, ERR_R_MALLOC_FAILURE);
- return NULL;
- }
-
- memcpy(item->priority, prio64be, sizeof(item->priority));
- item->data = data;
- item->next = NULL;
- return item;
-}
-
-void pitem_free(pitem *item)
-{
- OPENSSL_free(item);
-}
-
-pqueue *pqueue_new(void)
-{
- pqueue *pq = OPENSSL_zalloc(sizeof(*pq));
-
- if (pq == NULL)
- SSLerr(SSL_F_PQUEUE_NEW, ERR_R_MALLOC_FAILURE);
-
- return pq;
-}
-
-void pqueue_free(pqueue *pq)
-{
- OPENSSL_free(pq);
-}
-
-pitem *pqueue_insert(pqueue *pq, pitem *item)
-{
- pitem *curr, *next;
-
- if (pq->items == NULL) {
- pq->items = item;
- return item;
- }
-
- 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 */
- item->next = next;
-
- if (curr == NULL)
- pq->items = item;
- else
- curr->next = item;
-
- return item;
- }
-
- else if (cmp == 0) /* duplicates not allowed */
- return NULL;
- }
-
- item->next = NULL;
- curr->next = item;
-
- return item;
-}
-
-pitem *pqueue_peek(pqueue *pq)
-{
- return pq->items;
-}
-
-pitem *pqueue_pop(pqueue *pq)
-{
- pitem *item = pq->items;
-
- if (pq->items != NULL)
- pq->items = pq->items->next;
-
- return item;
-}
-
-pitem *pqueue_find(pqueue *pq, unsigned char *prio64be)
-{
- pitem *next;
- pitem *found = NULL;
-
- if (pq->items == NULL)
- return NULL;
-
- for (next = pq->items; next->next != NULL; next = next->next) {
- if (memcmp(next->priority, prio64be, 8) == 0) {
- found = next;
- break;
- }
- }
-
- /* check the one last node */
- if (memcmp(next->priority, prio64be, 8) == 0)
- found = next;
-
- if (!found)
- return NULL;
-
- return found;
-}
-
-pitem *pqueue_iterator(pqueue *pq)
-{
- return pqueue_peek(pq);
-}
-
-pitem *pqueue_next(piterator *item)
-{
- pitem *ret;
-
- if (item == NULL || *item == NULL)
- return NULL;
-
- /* *item != NULL */
- ret = *item;
- *item = (*item)->next;
-
- return ret;
-}
-
-size_t pqueue_size(pqueue *pq)
-{
- pitem *item = pq->items;
- size_t count = 0;
-
- while (item != NULL) {
- count++;
- item = item->next;
- }
- return count;
-}
+#include <openssl/bn.h>
+
+struct pqueue_st {
+ pitem *items;
+ int count;
+};
+
+pitem *pitem_new(unsigned char *prio64be, void *data)
+{
+ pitem *item = OPENSSL_malloc(sizeof(*item));
+
+ if (item == NULL) {
+ SSLerr(SSL_F_PITEM_NEW, ERR_R_MALLOC_FAILURE);
+ return NULL;
+ }
+
+ memcpy(item->priority, prio64be, sizeof(item->priority));
+ item->data = data;
+ item->next = NULL;
+ return item;
+}
+
+void pitem_free(pitem *item)
+{
+ OPENSSL_free(item);
+}
+
+pqueue *pqueue_new(void)
+{
+ pqueue *pq = OPENSSL_zalloc(sizeof(*pq));
+
+ if (pq == NULL)
+ SSLerr(SSL_F_PQUEUE_NEW, ERR_R_MALLOC_FAILURE);
+
+ return pq;
+}
+
+void pqueue_free(pqueue *pq)
+{
+ OPENSSL_free(pq);
+}
+
+pitem *pqueue_insert(pqueue *pq, pitem *item)
+{
+ pitem *curr, *next;
+
+ if (pq->items == NULL) {
+ pq->items = item;
+ return item;
+ }
+
+ 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 */
+ item->next = next;
+
+ if (curr == NULL)
+ pq->items = item;
+ else
+ curr->next = item;
+
+ return item;
+ }
+
+ else if (cmp == 0) /* duplicates not allowed */
+ return NULL;
+ }
+
+ item->next = NULL;
+ curr->next = item;
+
+ return item;
+}
+
+pitem *pqueue_peek(pqueue *pq)
+{
+ return pq->items;
+}
+
+pitem *pqueue_pop(pqueue *pq)
+{
+ pitem *item = pq->items;
+
+ if (pq->items != NULL)
+ pq->items = pq->items->next;
+
+ return item;
+}
+
+pitem *pqueue_find(pqueue *pq, unsigned char *prio64be)
+{
+ pitem *next;
+ pitem *found = NULL;
+
+ if (pq->items == NULL)
+ return NULL;
+
+ for (next = pq->items; next->next != NULL; next = next->next) {
+ if (memcmp(next->priority, prio64be, 8) == 0) {
+ found = next;
+ break;
+ }
+ }
+
+ /* check the one last node */
+ if (memcmp(next->priority, prio64be, 8) == 0)
+ found = next;
+
+ if (!found)
+ return NULL;
+
+ return found;
+}
+
+pitem *pqueue_iterator(pqueue *pq)
+{
+ return pqueue_peek(pq);
+}
+
+pitem *pqueue_next(piterator *item)
+{
+ pitem *ret;
+
+ if (item == NULL || *item == NULL)
+ return NULL;
+
+ /* *item != NULL */
+ ret = *item;
+ *item = (*item)->next;
+
+ return ret;
+}
+
+size_t pqueue_size(pqueue *pq)
+{
+ pitem *item = pq->items;
+ size_t count = 0;
+
+ while (item != NULL) {
+ count++;
+ item = item->next;
+ }
+ return count;
+}