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.

99 lines
3.5 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. uibuffer.hxx
  7. BUFFER class declaration
  8. FILE HISTORY:
  9. rustanl 03-Aug-1990 Created
  10. beng 30-Apr-1991 Uses lmui.hxx
  11. */
  12. #ifndef _UIBUFFER_HXX_
  13. #define _UIBUFFER_HXX_
  14. #include "base.hxx"
  15. /*************************************************************************
  16. NAME: BUFFER (buf)
  17. SYNOPSIS: A resizable object which lives in the application heap.
  18. Upon construction, the buffer takes a requested size in
  19. bytes; it allocates storage sufficient to hold that size.
  20. The client can later change this size with Resize, Trim,
  21. and FillOut. QuerySize returns the current size of
  22. the buffer; QueryPtr returns a pointer to its storage.
  23. Note that a buffer may have size 0, in which case it
  24. keeps no allocated storage. Hence the largest available
  25. buffer on OS/2 is 2^16-1 bytes.
  26. INTERFACE: BUFFER() - Constructor, naming initial size in bytes
  27. QuerySize() - return size in bytes
  28. QueryPtr() - return pointer to data buffer
  29. Resize() - resize the object to the given number
  30. of bytes. Returns 0 if the resize was
  31. successful; otherwise returns the OS
  32. errorcode.
  33. Trim() - force block to occupy no more storage
  34. than the client has requested.
  35. FillOut() - give client access to any additional
  36. storage occupied by the block.
  37. PARENT: BASE
  38. HISTORY:
  39. RustanL 3 Aug 90 Created
  40. DavidHov 5 Mar 91 Merged with BUFFER.HXX to supplant same
  41. beng 19-Jun-1991 Inherit from BASE; UINT sizes
  42. beng 15-Jul-1991 Resize returns APIERR instead of BOOL
  43. beng 19-Mar-1992 Remove OS/2 support
  44. **************************************************************************/
  45. DLL_CLASS BUFFER: public BASE
  46. {
  47. private:
  48. HANDLE _hMem; // Local/GlobalAlloc results
  49. BYTE * _pb; // pointer to storage
  50. UINT _cb; // size of storage, as requested by client
  51. inline VOID VerifyState() const;
  52. UINT QueryActualSize();
  53. APIERR GetNewStorage( UINT cbRequested );
  54. APIERR ReallocStorage( UINT cbNewlyRequested );
  55. public:
  56. BUFFER( UINT cbRequested = 0 );
  57. ~BUFFER();
  58. BYTE * QueryPtr() const;
  59. UINT QuerySize() const;
  60. APIERR Resize( UINT cbNewReqestedSize );
  61. // The following two methods deal with the difference between the
  62. // actual memory size and the requested size. These methods are
  63. // intended to be used when optimization is key.
  64. // Trim reallocates the buffer so that the actual space allocated is
  65. // minimally more than the size requested, whereas FillOut changes
  66. // (without actually reallocating) the requested size to the actual size.
  67. //
  68. VOID Trim();
  69. VOID FillOut();
  70. };
  71. #endif // _UIBUFFER_HXX_