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.

78 lines
2.5 KiB

  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 1998 Microsoft Corporation
  4. *
  5. * Module Name:
  6. *
  7. * Dynamic array implementation class
  8. *
  9. * Abstract:
  10. *
  11. * This class contains definitions of functions which can't (or shouldn't)
  12. * be inlined. We use a separate implementation class because this allows us
  13. * to avoid the code bloat template classes produce; every instance of the
  14. * DynArray template can use the same version of each out-of-line member.
  15. *
  16. * The DynArray data members need to be declared here, because they are
  17. * used by DynArrayImpl.
  18. *
  19. * Created:
  20. *
  21. * 2/18/1999 agodfrey
  22. *
  23. \**************************************************************************/
  24. class DynArrayImpl
  25. {
  26. protected:
  27. // Constructor
  28. //
  29. // initalAllocation - the initial allocation, which can be global,
  30. // static or dynamic memory (or NULL)
  31. // allocSize - size of the initial allocation
  32. // (0 if there is none)
  33. // stepSize - number of elements added each time the buffer grows
  34. DynArrayImpl(void *initialAllocation, UINT allocSize, UINT stepSize);
  35. // Shrink the buffer so that it is just big enough for the items
  36. // the dynamic array holds.
  37. VOID ShrinkToSize(UINT eltSize);
  38. // Add space for new elements (if necessary). Does not update Count.
  39. // eltSize - size of each element
  40. // newElements - number of new elements
  41. GpStatus Grow(UINT eltSize, UINT newElements);
  42. // Add new, uninitialized elements, and return a pointer to them.
  43. // eltSize - size of each element
  44. // newElements - number of new elements
  45. void *AddMultiple(UINT eltSize, UINT newElements);
  46. // Add new elements, initializing them with the given data.
  47. // eltSize - size of each element
  48. // newElements - number of new elements
  49. // newData - the data to be copied into the new space
  50. GpStatus AddMultiple(UINT eltSize, UINT newElements, const void *newData);
  51. // Detach the data buffer from the dynamic array.
  52. // Cannot be used if there is an initial allocation.
  53. void *DetachData();
  54. // Capacity, StepSize, AllocSize and Count are all measured in elements,
  55. // not bytes.
  56. void *DataBuffer;
  57. void *InitialAllocation;
  58. UINT AllocSize;
  59. UINT Capacity;
  60. UINT StepSize;
  61. UINT Count;
  62. };