Lines Matching refs:head
314 #define LL_PREPEND(head,add) \ argument
315 LL_PREPEND2(head,add,next)
317 #define LL_PREPEND2(head,add,next) \ argument
319 (add)->next = (head); \
320 (head) = (add); \
338 #define LL_APPEND(head,add) \ argument
339 LL_APPEND2(head,add,next)
341 #define LL_APPEND2(head,add,next) \ argument
343 LDECLTYPE(head) _tmp; \
345 if (head) { \
346 _tmp = (head); \
350 (head)=(add); \
354 #define LL_INSERT_INORDER(head,add,cmp) \ argument
355 LL_INSERT_INORDER2(head,add,cmp,next)
357 #define LL_INSERT_INORDER2(head,add,cmp,next) \ argument
359 LDECLTYPE(head) _tmp; \
360 if (head) { \
361 LL_LOWER_BOUND2(head, _tmp, add, cmp, next); \
362 LL_APPEND_ELEM2(head, _tmp, add, next); \
364 (head) = (add); \
365 (head)->next = NULL; \
369 #define LL_LOWER_BOUND(head,elt,like,cmp) \ argument
370 LL_LOWER_BOUND2(head,elt,like,cmp,next)
372 #define LL_LOWER_BOUND2(head,elt,like,cmp,next) \ argument
374 if ((head) == NULL || (cmp(head, like)) >= 0) { \
377 for ((elt) = (head); (elt)->next != NULL; (elt) = (elt)->next) { \
385 #define LL_DELETE(head,del) \ argument
386 LL_DELETE2(head,del,next)
388 #define LL_DELETE2(head,del,next) \ argument
390 LDECLTYPE(head) _tmp; \
391 if ((head) == (del)) { \
392 (head)=(head)->next; \
394 _tmp = (head); \
404 #define LL_COUNT(head,el,counter) \ argument
405 LL_COUNT2(head,el,counter,next) \
407 #define LL_COUNT2(head,el,counter,next) \ argument
410 LL_FOREACH2(head,el,next) { ++(counter); } \
413 #define LL_FOREACH(head,el) \ argument
414 LL_FOREACH2(head,el,next)
416 #define LL_FOREACH2(head,el,next) \ argument
417 for ((el) = (head); el; (el) = (el)->next)
419 #define LL_FOREACH_SAFE(head,el,tmp) \ argument
420 LL_FOREACH_SAFE2(head,el,tmp,next)
422 #define LL_FOREACH_SAFE2(head,el,tmp,next) \ argument
423 for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
425 #define LL_SEARCH_SCALAR(head,out,field,val) \ argument
426 LL_SEARCH_SCALAR2(head,out,field,val,next)
428 #define LL_SEARCH_SCALAR2(head,out,field,val,next) \ argument
430 LL_FOREACH2(head,out,next) { \
435 #define LL_SEARCH(head,out,elt,cmp) \ argument
436 LL_SEARCH2(head,out,elt,cmp,next)
438 #define LL_SEARCH2(head,out,elt,cmp,next) \ argument
440 LL_FOREACH2(head,out,next) { \
445 #define LL_REPLACE_ELEM2(head, el, add, next) \ argument
447 LDECLTYPE(head) _tmp; \
448 assert((head) != NULL); \
452 if ((head) == (el)) { \
453 (head) = (add); \
455 _tmp = (head); \
465 #define LL_REPLACE_ELEM(head, el, add) \ argument
466 LL_REPLACE_ELEM2(head, el, add, next)
468 #define LL_PREPEND_ELEM2(head, el, add, next) \ argument
471 LDECLTYPE(head) _tmp; \
472 assert((head) != NULL); \
475 if ((head) == (el)) { \
476 (head) = (add); \
478 _tmp = (head); \
487 LL_APPEND2(head, add, next); \
491 #define LL_PREPEND_ELEM(head, el, add) \ argument
492 LL_PREPEND_ELEM2(head, el, add, next)
494 #define LL_APPEND_ELEM2(head, el, add, next) \ argument
497 assert((head) != NULL); \
502 LL_PREPEND2(head, add, next); \
506 #define LL_APPEND_ELEM(head, el, add) \ argument
507 LL_APPEND_ELEM2(head, el, add, next)
527 #define LL_APPEND2(head,add,next) \ argument
529 if (head) { \
530 (add)->next = head; /* use add->next as a temp variable */ \
534 (head)=(add); \
540 #define LL_INSERT_INORDER2(head,add,cmp,next) \ argument
542 if ((head) == NULL || (cmp(head, add)) >= 0) { \
543 (add)->next = (head); \
544 (head) = (add); \
546 char *_tmp = (char*)(head); \
547 while ((head)->next != NULL && (cmp((head)->next, add)) < 0) { \
548 (head) = (head)->next; \
550 (add)->next = (head)->next; \
551 (head)->next = (add); \
552 UTLIST_RS(head); \
557 #define LL_DELETE2(head,del,next) \ argument
559 if ((head) == (del)) { \
560 (head)=(head)->next; \
562 char *_tmp = (char*)(head); \
563 while ((head)->next && ((head)->next != (del))) { \
564 (head) = (head)->next; \
566 if ((head)->next) { \
567 (head)->next = ((del)->next); \
569 UTLIST_RS(head); \
574 #define LL_REPLACE_ELEM2(head, el, add, next) \ argument
576 assert((head) != NULL); \
579 if ((head) == (el)) { \
580 (head) = (add); \
582 (add)->next = head; \
594 #define LL_PREPEND_ELEM2(head, el, add, next) \ argument
597 assert((head) != NULL); \
599 if ((head) == (el)) { \
600 (head) = (add); \
602 (add)->next = (head); \
612 LL_APPEND2(head, add, next); \
621 #define DL_PREPEND(head,add) \ argument
622 DL_PREPEND2(head,add,prev,next)
624 #define DL_PREPEND2(head,add,prev,next) \ argument
626 (add)->next = (head); \
627 if (head) { \
628 (add)->prev = (head)->prev; \
629 (head)->prev = (add); \
633 (head) = (add); \
636 #define DL_APPEND(head,add) \ argument
637 DL_APPEND2(head,add,prev,next)
639 #define DL_APPEND2(head,add,prev,next) \ argument
641 if (head) { \
642 (add)->prev = (head)->prev; \
643 (head)->prev->next = (add); \
644 (head)->prev = (add); \
647 (head)=(add); \
648 (head)->prev = (head); \
649 (head)->next = NULL; \
653 #define DL_INSERT_INORDER(head,add,cmp) \ argument
654 DL_INSERT_INORDER2(head,add,cmp,prev,next)
656 #define DL_INSERT_INORDER2(head,add,cmp,prev,next) \ argument
658 LDECLTYPE(head) _tmp; \
659 if (head) { \
660 DL_LOWER_BOUND2(head, _tmp, add, cmp, next); \
661 DL_APPEND_ELEM2(head, _tmp, add, prev, next); \
663 (head) = (add); \
664 (head)->prev = (head); \
665 (head)->next = NULL; \
669 #define DL_LOWER_BOUND(head,elt,like,cmp) \ argument
670 DL_LOWER_BOUND2(head,elt,like,cmp,next)
672 #define DL_LOWER_BOUND2(head,elt,like,cmp,next) \ argument
674 if ((head) == NULL || (cmp(head, like)) >= 0) { \
677 for ((elt) = (head); (elt)->next != NULL; (elt) = (elt)->next) { \
703 #define DL_DELETE(head,del) \ argument
704 DL_DELETE2(head,del,prev,next)
706 #define DL_DELETE2(head,del,prev,next) \ argument
708 assert((head) != NULL); \
711 (head)=NULL; \
712 } else if ((del)==(head)) { \
714 (head) = (del)->next; \
720 (head)->prev = (del)->prev; \
725 #define DL_COUNT(head,el,counter) \ argument
726 DL_COUNT2(head,el,counter,next) \
728 #define DL_COUNT2(head,el,counter,next) \ argument
731 DL_FOREACH2(head,el,next) { ++(counter); } \
734 #define DL_FOREACH(head,el) \ argument
735 DL_FOREACH2(head,el,next)
737 #define DL_FOREACH2(head,el,next) \ argument
738 for ((el) = (head); el; (el) = (el)->next)
741 #define DL_FOREACH_SAFE(head,el,tmp) \ argument
742 DL_FOREACH_SAFE2(head,el,tmp,next)
744 #define DL_FOREACH_SAFE2(head,el,tmp,next) \ argument
745 for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
753 #define DL_REPLACE_ELEM2(head, el, add, prev, next) \ argument
755 assert((head) != NULL); \
758 if ((head) == (el)) { \
759 (head) = (add); \
772 (head)->prev = (add); \
779 #define DL_REPLACE_ELEM(head, el, add) \ argument
780 DL_REPLACE_ELEM2(head, el, add, prev, next)
782 #define DL_PREPEND_ELEM2(head, el, add, prev, next) \ argument
785 assert((head) != NULL); \
790 if ((head) == (el)) { \
791 (head) = (add); \
796 DL_APPEND2(head, add, prev, next); \
800 #define DL_PREPEND_ELEM(head, el, add) \ argument
801 DL_PREPEND_ELEM2(head, el, add, prev, next)
803 #define DL_APPEND_ELEM2(head, el, add, prev, next) \ argument
806 assert((head) != NULL); \
814 (head)->prev = (add); \
817 DL_PREPEND2(head, add, prev, next); \
821 #define DL_APPEND_ELEM(head, el, add) \ argument
822 DL_APPEND_ELEM2(head, el, add, prev, next)
828 #define DL_INSERT_INORDER2(head,add,cmp,prev,next) \ argument
830 if ((head) == NULL) { \
833 (head) = (add); \
834 } else if ((cmp(head, add)) >= 0) { \
835 (add)->prev = (head)->prev; \
836 (add)->next = (head); \
837 (head)->prev = (add); \
838 (head) = (add); \
840 char *_tmp = (char*)(head); \
841 while ((head)->next && (cmp((head)->next, add)) < 0) { \
842 (head) = (head)->next; \
844 (add)->prev = (head); \
845 (add)->next = (head)->next; \
846 (head)->next = (add); \
847 UTLIST_RS(head); \
851 (head)->prev = (add); \
860 #define CDL_APPEND(head,add) \ argument
861 CDL_APPEND2(head,add,prev,next)
863 #define CDL_APPEND2(head,add,prev,next) \ argument
865 if (head) { \
866 (add)->prev = (head)->prev; \
867 (add)->next = (head); \
868 (head)->prev = (add); \
873 (head) = (add); \
877 #define CDL_PREPEND(head,add) \ argument
878 CDL_PREPEND2(head,add,prev,next)
880 #define CDL_PREPEND2(head,add,prev,next) \ argument
882 if (head) { \
883 (add)->prev = (head)->prev; \
884 (add)->next = (head); \
885 (head)->prev = (add); \
891 (head) = (add); \
894 #define CDL_INSERT_INORDER(head,add,cmp) \ argument
895 CDL_INSERT_INORDER2(head,add,cmp,prev,next)
897 #define CDL_INSERT_INORDER2(head,add,cmp,prev,next) \ argument
899 LDECLTYPE(head) _tmp; \
900 if (head) { \
901 CDL_LOWER_BOUND2(head, _tmp, add, cmp, next); \
902 CDL_APPEND_ELEM2(head, _tmp, add, prev, next); \
904 (head) = (add); \
905 (head)->next = (head); \
906 (head)->prev = (head); \
910 #define CDL_LOWER_BOUND(head,elt,like,cmp) \ argument
911 CDL_LOWER_BOUND2(head,elt,like,cmp,next)
913 #define CDL_LOWER_BOUND2(head,elt,like,cmp,next) \ argument
915 if ((head) == NULL || (cmp(head, like)) >= 0) { \
918 for ((elt) = (head); (elt)->next != (head); (elt) = (elt)->next) { \
926 #define CDL_DELETE(head,del) \ argument
927 CDL_DELETE2(head,del,prev,next)
929 #define CDL_DELETE2(head,del,prev,next) \ argument
931 if (((head)==(del)) && ((head)->next == (head))) { \
932 (head) = NULL; \
936 if ((del) == (head)) (head)=(del)->next; \
940 #define CDL_COUNT(head,el,counter) \ argument
941 CDL_COUNT2(head,el,counter,next) \
943 #define CDL_COUNT2(head, el, counter,next) \ argument
946 CDL_FOREACH2(head,el,next) { ++(counter); } \
949 #define CDL_FOREACH(head,el) \ argument
950 CDL_FOREACH2(head,el,next)
952 #define CDL_FOREACH2(head,el,next) \ argument
953 for ((el)=(head);el;(el)=(((el)->next==(head)) ? NULL : (el)->next))
955 #define CDL_FOREACH_SAFE(head,el,tmp1,tmp2) \ argument
956 CDL_FOREACH_SAFE2(head,el,tmp1,tmp2,prev,next)
958 #define CDL_FOREACH_SAFE2(head,el,tmp1,tmp2,prev,next) \ argument
959 for ((el) = (head), (tmp1) = (head) ? (head)->prev : NULL; \
963 #define CDL_SEARCH_SCALAR(head,out,field,val) \ argument
964 CDL_SEARCH_SCALAR2(head,out,field,val,next)
966 #define CDL_SEARCH_SCALAR2(head,out,field,val,next) \ argument
968 CDL_FOREACH2(head,out,next) { \
973 #define CDL_SEARCH(head,out,elt,cmp) \ argument
974 CDL_SEARCH2(head,out,elt,cmp,next)
976 #define CDL_SEARCH2(head,out,elt,cmp,next) \ argument
978 CDL_FOREACH2(head,out,next) { \
983 #define CDL_REPLACE_ELEM2(head, el, add, prev, next) \ argument
985 assert((head) != NULL); \
991 (head) = (add); \
997 if ((head) == (el)) { \
998 (head) = (add); \
1003 #define CDL_REPLACE_ELEM(head, el, add) \ argument
1004 CDL_REPLACE_ELEM2(head, el, add, prev, next)
1006 #define CDL_PREPEND_ELEM2(head, el, add, prev, next) \ argument
1009 assert((head) != NULL); \
1015 if ((head) == (el)) { \
1016 (head) = (add); \
1019 CDL_APPEND2(head, add, prev, next); \
1023 #define CDL_PREPEND_ELEM(head, el, add) \ argument
1024 CDL_PREPEND_ELEM2(head, el, add, prev, next)
1026 #define CDL_APPEND_ELEM2(head, el, add, prev, next) \ argument
1029 assert((head) != NULL); \
1036 CDL_PREPEND2(head, add, prev, next); \
1040 #define CDL_APPEND_ELEM(head, el, add) \ argument
1041 CDL_APPEND_ELEM2(head, el, add, prev, next)
1047 #define CDL_INSERT_INORDER2(head,add,cmp,prev,next) \ argument
1049 if ((head) == NULL) { \
1052 (head) = (add); \
1053 } else if ((cmp(head, add)) >= 0) { \
1054 (add)->prev = (head)->prev; \
1055 (add)->next = (head); \
1057 (head)->prev = (add); \
1058 (head) = (add); \
1060 char *_tmp = (char*)(head); \
1061 while ((char*)(head)->next != _tmp && (cmp((head)->next, add)) < 0) { \
1062 (head) = (head)->next; \
1064 (add)->prev = (head); \
1065 (add)->next = (head)->next; \
1067 (head)->next = (add); \
1068 UTLIST_RS(head); \