MCPcopy Create free account
hub / github.com/devsisters/libquic / pqueue_insert

Function pqueue_insert

boringssl/ssl/pqueue/pqueue.c:153–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151}
152
153pitem *pqueue_insert(pqueue_s *pq, pitem *item) {
154 pitem *curr, *next;
155
156 if (pq->items == NULL) {
157 pq->items = item;
158 return item;
159 }
160
161 for (curr = NULL, next = pq->items; next != NULL;
162 curr = next, next = next->next) {
163 /* we can compare 64-bit value in big-endian encoding with memcmp. */
164 int cmp = memcmp(next->priority, item->priority, sizeof(item->priority));
165 if (cmp > 0) {
166 /* next > item */
167 item->next = next;
168
169 if (curr == NULL) {
170 pq->items = item;
171 } else {
172 curr->next = item;
173 }
174
175 return item;
176 } else if (cmp == 0) {
177 /* duplicates not allowed */
178 return NULL;
179 }
180 }
181
182 item->next = NULL;
183 curr->next = item;
184
185 return item;
186}
187
188
189pitem *pqueue_pop(pqueue_s *pq) {

Callers 5

dtls1_buffer_messageFunction · 0.85
trivialFunction · 0.85
fixed_randomFunction · 0.85

Calls

no outgoing calls

Tested by 2

trivialFunction · 0.68
fixed_randomFunction · 0.68