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.

106 lines
2.4 KiB

  1. /*
  2. * ptrarray.h - Pointer array ADT description.
  3. */
  4. /* Constants
  5. ************/
  6. /*
  7. * ARRAYINDEX_MAX is set such that (ARRAYINDEX_MAX + 1) does not overflow an
  8. * ARRAYINDEX. This guarantee allows GetPtrCount() to return a count of
  9. * pointers as an ARRAYINDEX.
  10. */
  11. #define ARRAYINDEX_MAX (LONG_MAX - 1)
  12. /* Types
  13. ********/
  14. /* handles */
  15. DECLARE_HANDLE(HPTRARRAY);
  16. DECLARE_STANDARD_TYPES(HPTRARRAY);
  17. /* array index */
  18. typedef LONG ARRAYINDEX;
  19. DECLARE_STANDARD_TYPES(ARRAYINDEX);
  20. /*
  21. * pointer comparison callback function
  22. *
  23. * In sorting functions, both pointers are pointer array elements. In
  24. * searching functions, the first pointer is reference data and the second
  25. * pointer is a pointer array element.
  26. */
  27. typedef COMPARISONRESULT (*COMPARESORTEDPTRSPROC)(PCVOID, PCVOID);
  28. /*
  29. * pointer comparison callback function
  30. *
  31. * In searching functions, the first pointer is reference data and the second
  32. * pointer is a pointer array element.
  33. */
  34. typedef BOOL (*COMPAREUNSORTEDPTRSPROC)(PCVOID, PCVOID);
  35. /* new pointer array flags */
  36. typedef enum _newptrarrayflags
  37. {
  38. /* Insert elements in sorted order. */
  39. NPA_FL_SORTED_ADD = 0x0001,
  40. /* flag combinations */
  41. ALL_NPA_FLAGS = NPA_FL_SORTED_ADD
  42. }
  43. NEWPTRARRAYFLAGS;
  44. /* new pointer array description */
  45. typedef struct _newptrarray
  46. {
  47. DWORD dwFlags;
  48. ARRAYINDEX aicInitialPtrs;
  49. ARRAYINDEX aicAllocGranularity;
  50. }
  51. NEWPTRARRAY;
  52. DECLARE_STANDARD_TYPES(NEWPTRARRAY);
  53. /* Prototypes
  54. *************/
  55. /* ptrarray.c */
  56. extern BOOL CreatePtrArray(PCNEWPTRARRAY, PHPTRARRAY);
  57. extern void DestroyPtrArray(HPTRARRAY);
  58. extern BOOL InsertPtr(HPTRARRAY, COMPARESORTEDPTRSPROC, ARRAYINDEX, PCVOID);
  59. extern BOOL AddPtr(HPTRARRAY, COMPARESORTEDPTRSPROC, PCVOID, PARRAYINDEX);
  60. extern void DeletePtr(HPTRARRAY, ARRAYINDEX);
  61. extern void DeleteAllPtrs(HPTRARRAY);
  62. extern ARRAYINDEX GetPtrCount(HPTRARRAY);
  63. extern PVOID GetPtr(HPTRARRAY, ARRAYINDEX);
  64. extern void SortPtrArray(HPTRARRAY, COMPARESORTEDPTRSPROC);
  65. extern BOOL SearchSortedArray(HPTRARRAY, COMPARESORTEDPTRSPROC, PCVOID, PARRAYINDEX);
  66. extern BOOL LinearSearchArray(HPTRARRAY, COMPAREUNSORTEDPTRSPROC, PCVOID, PARRAYINDEX);
  67. #if defined(DEBUG) || defined(VSTF)
  68. extern BOOL IsValidHPTRARRAY(HPTRARRAY);
  69. #endif
  70. #ifdef VSTF
  71. extern BOOL IsValidHGLOBAL(HGLOBAL);
  72. #endif