Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.9 KiB

  1. /*
  2. ************************************************************************
  3. *
  4. * SYNC.C
  5. *
  6. * Copyright (C) 1996-2001 Microsoft Corporation. All Rights Reserved.
  7. *
  8. *
  9. *
  10. *************************************************************************
  11. */
  12. #include <ndis.h>
  13. #include <ntddndis.h>
  14. #include "sync.h"
  15. void CheckForEntryOnList(PLIST_ENTRY Head, PLIST_ENTRY Entry)
  16. {
  17. PLIST_ENTRY ListEntry;
  18. for (ListEntry = Head->Flink;
  19. ListEntry != Head->Flink;
  20. ListEntry = ListEntry->Flink
  21. )
  22. {
  23. if (Entry==ListEntry)
  24. {
  25. DbgPrint("About to insert entry that is already on list!\n");
  26. DbgPrint("Head:%08X Entry:%08X\n", Head, Entry);
  27. DbgBreakPoint();
  28. break;
  29. }
  30. }
  31. }
  32. BOOLEAN SynchronizedListFunc(IN PVOID Context)
  33. {
  34. SynchronizeList *ListData = Context;
  35. switch (ListData->Command)
  36. {
  37. case SyncInsertHead:
  38. // CheckForEntryOnList(ListData->Head, ListData->Entry);
  39. InsertHeadList(ListData->Head, ListData->Entry);
  40. break;
  41. case SyncInsertTail:
  42. // CheckForEntryOnList(ListData->Head, ListData->Entry);
  43. InsertTailList(ListData->Head, ListData->Entry);
  44. break;
  45. case SyncRemoveHead:
  46. if (IsListEmpty(ListData->Head))
  47. {
  48. ListData->Entry = NULL;
  49. }
  50. else
  51. {
  52. ListData->Entry = RemoveHeadList(ListData->Head);
  53. }
  54. break;
  55. case SyncRemoveTail:
  56. if (IsListEmpty(ListData->Head))
  57. {
  58. ListData->Entry = NULL;
  59. }
  60. else
  61. {
  62. ListData->Entry = RemoveTailList(ListData->Head);
  63. }
  64. break;
  65. case SyncRemove:
  66. RemoveEntryList(ListData->Entry);
  67. break;
  68. default:
  69. ASSERT(0);
  70. break;
  71. }
  72. return TRUE;
  73. }