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.

111 lines
3.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: cntxlist.cxx
  7. //
  8. // Contents: CContextList implementation
  9. //
  10. // History: 26-Oct-92 DrewB Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #include <exphead.cxx>
  14. #pragma hdrstop
  15. #include <cntxlist.hxx>
  16. //+---------------------------------------------------------------------------
  17. //
  18. // Member: CContextList::_Find, 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: 26-Oct-92 DrewB Created
  27. //
  28. //----------------------------------------------------------------------------
  29. #ifdef CODESEGMENTS
  30. #pragma code_seg(SEG_CContextList_Find)
  31. #endif
  32. CContext *CContextList::_Find(ContextId ctxid)
  33. {
  34. CBasedContextPtr pctx;
  35. olDebugOut((DEB_ITRACE, "In CContextList::_Find:%p(%lu)\n", this,
  36. (ULONG)ctxid));
  37. for (pctx = _pctxHead; pctx; pctx = pctx->pctxNext)
  38. if (pctx->ctxid != INVALID_CONTEXT_ID &&
  39. pctx->ctxid == ctxid)
  40. break;
  41. olDebugOut((DEB_ITRACE, "Out CContextList::_Find\n"));
  42. return BP_TO_P(CContext *, pctx);
  43. }
  44. //+---------------------------------------------------------------------------
  45. //
  46. // Member: CContextList::Add, public
  47. //
  48. // Synopsis: Adds a context to the list
  49. //
  50. // Arguments: [pctx] - Context
  51. //
  52. // History: 26-Oct-92 DrewB Created
  53. //
  54. //----------------------------------------------------------------------------
  55. #ifdef CODESEGMENTS
  56. #pragma code_seg(SEG_CContextList_Add)
  57. #endif
  58. void CContextList::Add(CContext *pctx)
  59. {
  60. olDebugOut((DEB_ITRACE, "In CContextList::Add:%p(%p)\n", this, pctx));
  61. pctx->pctxNext = _pctxHead;
  62. pctx->ctxid = GetCurrentContextId();
  63. _pctxHead = P_TO_BP(CBasedContextPtr, pctx);
  64. olDebugOut((DEB_ITRACE, "Out CContextList::Add\n"));
  65. }
  66. //+---------------------------------------------------------------------------
  67. //
  68. // Member: CContextList::Remove, public
  69. //
  70. // Synopsis: Removes a context from the list
  71. //
  72. // Arguments: [pctx] - Context
  73. //
  74. // History: 26-Oct-92 DrewB Created
  75. //
  76. //----------------------------------------------------------------------------
  77. #ifdef CODESEGMENTS
  78. #pragma code_seg(SEG_CContextList_Remove)
  79. #endif
  80. void CContextList::Remove(CContext *pctx)
  81. {
  82. CBasedContextPtr *ppctx;
  83. #if DBG == 1
  84. BOOL fFound = FALSE;
  85. #endif
  86. olDebugOut((DEB_ITRACE, "In CContextList::Remove:%p(%p)\n", this, pctx));
  87. for (ppctx = &_pctxHead; *ppctx; ppctx = &(*ppctx)->pctxNext)
  88. if (*ppctx == pctx)
  89. {
  90. #if DBG == 1
  91. fFound = TRUE;
  92. #endif
  93. *ppctx = pctx->pctxNext;
  94. break;
  95. }
  96. olAssert(fFound == TRUE);
  97. olDebugOut((DEB_ITRACE, "Out CContextList::Remove\n"));
  98. }