MCPcopy Create free account
hub / github.com/dillo-browser/dillo / dList_insert_sorted

Function dList_insert_sorted

dlib/dlib.c:769–789  ·  view source on GitHub ↗

* Insert an element into a sorted list. * The comparison function receives two list elements. */

Source from the content-addressed store, hash-verified

767 * The comparison function receives two list elements.
768 */
769void dList_insert_sorted (Dlist *lp, void *data, dCompareFunc func)
770{
771 int i, st, min, max;
772
773 if (lp) {
774 min = st = i = 0;
775 max = lp->len - 1;
776 while (min <= max) {
777 i = (min + max) / 2;
778 st = func(lp->list[i], data);
779 if (st < 0) {
780 min = i + 1;
781 } else if (st > 0) {
782 max = i - 1;
783 } else {
784 break;
785 }
786 }
787 dList_insert_pos(lp, data, (st >= 0) ? i : i+1);
788 }
789}
790
791/**
792 * Search a sorted list.

Callers 10

Cookies_add_cookieFunction · 0.85
initMethod · 0.85
parseKeyMethod · 0.85
Cache_entry_addFunction · 0.85
a_Klist_insertFunction · 0.85
Dicache_add_entryFunction · 0.85
Hsts_set_policyFunction · 0.85

Calls 1

dList_insert_posFunction · 0.85

Tested by

no test coverage detected