Leaked source code of windows server 2003
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.

119 lines
3.7 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: mrshlist.cxx
  7. //
  8. // Contents: CMarshalList implementation
  9. //
  10. // History: 16-Mar-96 HenryLee Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #include <exphead.cxx>
  14. #pragma hdrstop
  15. #include <mrshlist.hxx>
  16. //+---------------------------------------------------------------------------
  17. //
  18. // Member: CMarshalList::FindMarshal, public
  19. //
  20. // Synopsis: Looks through the list for a matching context
  21. //
  22. // Arguments: [ctxid] - Context to look for
  23. //
  24. // Returns: Pointer to object or NULL
  25. //
  26. // History: 16-Mar-96 HenryLee Created
  27. //
  28. //----------------------------------------------------------------------------
  29. CMarshalList *CMarshalList::FindMarshal (ContextId ctxid) const
  30. {
  31. CMarshalList *pmlResult = NULL;
  32. olDebugOut((DEB_ITRACE, "In CMarshalList::Find:%p(%lu)Marshal\n", this,
  33. (ULONG)ctxid));
  34. olAssert (ctxid != INVALID_CONTEXT_ID);
  35. if (GetContextId() == ctxid)
  36. pmlResult = (CMarshalList *) this; // cast away const
  37. else
  38. {
  39. CMarshalList *pml;
  40. for (pml = GetNextMarshal(); pml != this; pml = pml->GetNextMarshal())
  41. {
  42. olAssert (pml != NULL);
  43. if (pml->GetContextId() != INVALID_CONTEXT_ID &&
  44. pml->GetContextId() == ctxid)
  45. {
  46. pmlResult = pml;
  47. break;
  48. }
  49. }
  50. }
  51. olDebugOut((DEB_ITRACE, "Out CMarshalList::FindMarshal %p\n", pmlResult));
  52. return pmlResult;
  53. }
  54. //+---------------------------------------------------------------------------
  55. //
  56. // Member: CMarshalList::AddMarshal, public
  57. //
  58. // Synopsis: Adds a context to the list
  59. //
  60. // Arguments: [pml] - another marshaling of the same storage/stream
  61. //
  62. // History: 16-Mar-96 HenryLee Created
  63. //
  64. //----------------------------------------------------------------------------
  65. void CMarshalList::AddMarshal (CMarshalList *pml)
  66. {
  67. olDebugOut((DEB_ITRACE, "In CMarshalList::AddMarshal:%p(%p)\n",this,pml));
  68. olAssert (pml != NULL);
  69. olAssert (GetNextMarshal() != NULL);
  70. pml->SetNextMarshal(GetNextMarshal());
  71. SetNextMarshal(pml);
  72. olDebugOut((DEB_ITRACE, "Out CMarshalList::AddMarshal\n"));
  73. }
  74. //+---------------------------------------------------------------------------
  75. //
  76. // Member: CMarshalList::RemoveMarshal, public
  77. //
  78. // Synopsis: Removes a context from the list
  79. //
  80. // Arguments: [pctx] - Context
  81. //
  82. // History: 16-Mar-96 HenryLee Created
  83. //
  84. //----------------------------------------------------------------------------
  85. void CMarshalList::RemoveMarshal(CMarshalList *pml)
  86. {
  87. olDebugOut((DEB_ITRACE, "In CMarshalList::RemoveMarshal:%p(%p)\n",
  88. this,pml));
  89. if (GetNextMarshal() != NULL && GetNextMarshal() != this)
  90. {
  91. CMarshalList *pmlNext;
  92. #if DBG == 1
  93. BOOL fFound = FALSE;
  94. #endif
  95. for (pmlNext = GetNextMarshal(); pmlNext != this;
  96. pmlNext = pmlNext->GetNextMarshal())
  97. if (pmlNext->GetNextMarshal() == pml)
  98. {
  99. #if DBG == 1
  100. fFound = TRUE;
  101. #endif
  102. pmlNext->SetNextMarshal(pml->GetNextMarshal());
  103. pml->SetNextMarshal(NULL);
  104. break;
  105. }
  106. olAssert(fFound == TRUE);
  107. }
  108. olDebugOut((DEB_ITRACE, "Out CMarshalList::RemoveMarshal\n"));
  109. }