MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / naptr_sort

Function naptr_sort

modules/enum/enum.c:494–530  ·  view source on GitHub ↗

* Bubble sorts result record list according to naptr (order,preference). */

Source from the content-addressed store, hash-verified

492 * Bubble sorts result record list according to naptr (order,preference).
493 */
494static inline void naptr_sort(struct rdata** head)
495{
496 struct rdata *p, *q, *r, *s, *temp, *start;
497
498 /* r precedes p and s points to the node up to which comparisons
499 are to be made */
500
501 s = NULL;
502 start = *head;
503 while ( s != start -> next ) {
504 r = p = start ;
505 q = p -> next ;
506 while ( p != s ) {
507 if ( naptr_greater(p, q) ) {
508 if ( p == start ) {
509 temp = q -> next ;
510 q -> next = p ;
511 p -> next = temp ;
512 start = q ;
513 r = q ;
514 } else {
515 temp = q -> next ;
516 q -> next = p ;
517 p -> next = temp ;
518 r -> next = q ;
519 r = q ;
520 }
521 } else {
522 r = p ;
523 p = p -> next ;
524 }
525 q = p -> next ;
526 if ( q == s ) s = p ;
527 }
528 }
529 *head = start;
530}
531
532
533/*

Callers 1

do_queryFunction · 0.70

Calls 1

naptr_greaterFunction · 0.70

Tested by

no test coverage detected