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.

83 lines
2.7 KiB

  1. #include "precomp.h"
  2. /*
  3. * memory.cpp
  4. *
  5. * Copyright (c) 1993 - 1995 by DataBeam Corporation, Lexington, KY
  6. *
  7. * Abstract:
  8. * This is the implementation file for the Memory class. Instances of
  9. * this class represent chunks of data that are passed through a system.
  10. * This class is particularly useful in cases where a memory buffer
  11. * needs to be used in several different places, none of which know
  12. * about each other. This is because this class encapsulates things
  13. * like lock counts, which are useful for holding memory until
  14. * everyone that needs it is through.
  15. *
  16. * Note that this class does NOT do memory management. It is told by
  17. * a higher level memory manager where its buffers are, etc. For this
  18. * reason, this class does not do any platform specific calls.
  19. *
  20. * Private Instance Variables:
  21. * Length
  22. * This is the length of the reference buffer.
  23. * Copy_Ptr
  24. * This is the address of the allocated buffer that this object
  25. * uses.
  26. * Free_Stack
  27. * This is a pointer to the free stack list from which the copy
  28. * buffer was allocated. This is held within this object as a
  29. * convenience to the memory manager, allowing it to return the
  30. * buffer to the free pool more quickly and easily.
  31. * Block_Number
  32. * This is the block number of the memory block that this object
  33. * represents. This is held within this object as a convenience to
  34. * the memory manager, allowing it to return the buffer to the free
  35. * pool more quickly and easily.
  36. * Memory_Lock_Mode
  37. * This fields indicates whether this memory object should be destroyed
  38. * only when the lock count on the memory buffer reaches zero (NORMAL),
  39. * or whether its okay to destroy immediately when the memory block is
  40. * freed (IGNORED).
  41. *
  42. * Private Member Functions:
  43. * None.
  44. *
  45. * Caveats:
  46. * None.
  47. *
  48. * Author:
  49. * James P. Galvin, Jr.
  50. */
  51. /*
  52. * Memory ()
  53. *
  54. * Public
  55. *
  56. * Functional Description:
  57. * This is the constructor for the Memory class. It just initializes
  58. * all instance variable, based on the passed in values.
  59. */
  60. Memory::Memory (
  61. PUChar reference_ptr,
  62. ULong length,
  63. PUChar copy_ptr,
  64. BlockNumber block_number,
  65. MemoryLockMode memory_lock_mode) :
  66. Length (length), Copy_Ptr (copy_ptr),
  67. Block_Number (block_number), Memory_Lock_Mode (memory_lock_mode)
  68. {
  69. /*
  70. * If the reference pointer is a valid pointer, then the pointer type
  71. * will be set to reference (indicating that the reference data has not
  72. * yet been copied). If the reference pointer is NULL, then this is
  73. * a memory allocation with no associated reference data, so set the
  74. * pointer type to copy.
  75. */
  76. if (reference_ptr != NULL)
  77. memcpy (Copy_Ptr, reference_ptr, (Int) Length);
  78. }