list.c 700 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include <aos/list.h>
  2. void slist_add_tail(slist_t *node, slist_t *head)
  3. {
  4. while (head->next) {
  5. head = head->next;
  6. }
  7. slist_add(node, head);
  8. }
  9. void slist_del(slist_t *node, slist_t *head)
  10. {
  11. while (head->next) {
  12. if (head->next == node) {
  13. head->next = node->next;
  14. break;
  15. }
  16. head = head->next;
  17. }
  18. }
  19. int slist_entry_number(slist_t *queue)
  20. {
  21. int num;
  22. slist_t *cur = queue;
  23. for (num=0; cur->next; cur=cur->next, num++)
  24. ;
  25. return num;
  26. }
  27. int dlist_entry_number(dlist_t *queue)
  28. {
  29. int num;
  30. dlist_t *cur = queue;
  31. for (num=0; cur->next != queue; cur=cur->next, num++)
  32. ;
  33. return num;
  34. }