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.

72 lines
1.2 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. htable.h
  5. Abstract:
  6. Handle table
  7. Author:
  8. Erez Haba (erezh) 10-Mar-97
  9. Revision History:
  10. --*/
  11. #ifndef __HTABLE_H
  12. #define __HTABLE_H
  13. //---------------------------------------------------------
  14. //
  15. // class CHTable
  16. //
  17. //---------------------------------------------------------
  18. class CHTable {
  19. enum {
  20. GrowSize = 16, // N.B. must be a power of 2
  21. ShrinkSize = 24 // N.B. must be greater than GrowSize
  22. };
  23. public:
  24. CHTable();
  25. ~CHTable();
  26. HACCursor32 CreateHandle(PVOID Object);
  27. PVOID ReferenceObject(HACCursor32 Handle);
  28. PVOID CloseHandle(HACCursor32 Handle);
  29. private:
  30. void Grow();
  31. void Shrink();
  32. void Reallocate(ULONG nObjects);
  33. private:
  34. ULONG m_nObjects;
  35. ULONG m_ixTop;
  36. PVOID* m_pObjects;
  37. };
  38. //---------------------------------------------------------
  39. //
  40. // IMPLEMENTATION
  41. //
  42. //---------------------------------------------------------
  43. inline CHTable::CHTable() :
  44. m_nObjects(0),
  45. m_ixTop(0),
  46. m_pObjects(0)
  47. {
  48. }
  49. inline CHTable::~CHTable()
  50. {
  51. ASSERT(m_ixTop == 0);
  52. delete[] m_pObjects;
  53. }
  54. #endif // __HTABLE_H