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.

91 lines
2.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1994.
  5. //
  6. // File: tblrowal.hxx
  7. //
  8. // Contents: Declaration of the CTableRowAlloc class, used in allocation
  9. // of table row data and checking of column bindings.
  10. //
  11. // Classes: CTableRowAlloc
  12. //
  13. // History: 27 Jun 1994 Alanw Created
  14. //
  15. //--------------------------------------------------------------------------
  16. #pragma once
  17. #ifdef DISPLAY_INCLUDES
  18. #pragma message( "#include <" __FILE__ ">..." )
  19. #endif
  20. //+-------------------------------------------------------------------------
  21. //
  22. // Class: CTableRowAlloc
  23. //
  24. // Purpose: Track assignment of fields within a table row. Used to
  25. // check column bindings and to allocate appropriately
  26. // aligned memory to a table window.
  27. //
  28. // Interface:
  29. //
  30. //--------------------------------------------------------------------------
  31. class CTableRowAlloc : INHERIT_UNWIND
  32. {
  33. DECLARE_UNWIND
  34. enum { CB_INIT = 256 };
  35. public:
  36. CTableRowAlloc( unsigned cbRow = 0 );
  37. ~CTableRowAlloc()
  38. {
  39. if ( _pRowMap != _aRowMap )
  40. {
  41. delete [] _pRowMap;
  42. }
  43. }
  44. // Allocate a column in a row, return offset in row
  45. USHORT AllocOffset( unsigned cbData, unsigned cbAlign, BOOL fGrow );
  46. // Reserve a run of data; return TRUE if successful
  47. BOOL ReserveRowSpace( unsigned iOffset, unsigned cbData );
  48. // Retrieve required row width
  49. USHORT GetRowWidth( void ) {
  50. return _maxRow;
  51. }
  52. // Set required row width, if greater than the current maximum.
  53. USHORT SetRowWidth( unsigned width ) {
  54. Win4Assert(width > 0 && width < USHRT_MAX);
  55. if (width > _maxRow)
  56. _maxRow = (WORD)width;
  57. return _maxRow;
  58. }
  59. private:
  60. BOOL _IsLikelyFree( unsigned iOffset, unsigned cbData );
  61. BOOL _IsInUse( unsigned i )
  62. {
  63. Win4Assert( i < _cbRow );
  64. return _pRowMap[i];
  65. }
  66. USHORT _maxRow; // required width of row
  67. USHORT _cbRow; // size of _pRowMap
  68. BYTE* _pRowMap; // Row map data
  69. // OPTIMIZATION to avoid doing memory allocations if possible.
  70. BYTE _aRowMap[CB_INIT];
  71. unsigned _iFirstFree; // Index of the first free entry in the map
  72. // OPTIMIZATION
  73. };