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.

189 lines
5.3 KiB

  1. //========================================================================
  2. // Copyright (C) 1997 Microsoft Corporation
  3. // Author: RameshV
  4. // Description: This file has been generated. Pl look at the .c file
  5. //========================================================================
  6. typedef struct _ARRAY {
  7. DWORD nElements;
  8. DWORD nAllocated;
  9. LPVOID *Ptrs;
  10. } ARRAY, *PARRAY, *LPARRAY;
  11. typedef DWORD ARRAY_LOCATION;
  12. typedef ARRAY_LOCATION* PARRAY_LOCATION;
  13. typedef PARRAY_LOCATION LPARRAY_LOCATION;
  14. DWORD _inline
  15. MemArrayInit( // initialize the STRUCTURE
  16. OUT PARRAY Array // input structure pre-allocated
  17. ) {
  18. AssertRet(Array, ERROR_INVALID_PARAMETER);
  19. Array->nElements = Array->nAllocated = 0;
  20. Array->Ptrs = NULL;
  21. return ERROR_SUCCESS;
  22. }
  23. DWORD _inline
  24. MemArrayCleanup( // freeup the memory if any, allocated in this module
  25. IN OUT PARRAY Array
  26. ) {
  27. AssertRet(Array, ERROR_INVALID_PARAMETER);
  28. if( Array->Ptrs) MemFree(Array->Ptrs);
  29. Array->nElements = Array->nAllocated = 0;
  30. Array->Ptrs = NULL;
  31. return ERROR_SUCCESS;
  32. }
  33. DWORD _inline
  34. MemArraySize(
  35. IN PARRAY Array
  36. ) {
  37. AssertRet(Array, ERROR_INVALID_PARAMETER);
  38. return Array->nElements;
  39. }
  40. DWORD _inline
  41. MemArrayInitLoc( // Initialize an array location
  42. IN PARRAY Array,
  43. IN OUT PARRAY_LOCATION Location
  44. ) {
  45. AssertRet(Array && Location, ERROR_INVALID_PARAMETER);
  46. (*Location) = 0;
  47. if( 0 == Array->nElements ) return ERROR_FILE_NOT_FOUND;
  48. return ERROR_SUCCESS;
  49. }
  50. BOOL _inline
  51. MemArrayValidLoc(
  52. IN PARRAY Array,
  53. IN PARRAY_LOCATION Location
  54. )
  55. {
  56. AssertRet(Array && Location, FALSE);
  57. return ( *Location < Array->nElements );
  58. }
  59. DWORD _inline
  60. MemArrayNextLoc( // move one step forward
  61. IN PARRAY Array,
  62. IN OUT PARRAY_LOCATION Location
  63. ) {
  64. AssertRet(Array && Location, ERROR_INVALID_PARAMETER);
  65. if( (*Location) + 1 >= Array->nElements ) return ERROR_FILE_NOT_FOUND;
  66. (*Location) ++;
  67. return ERROR_SUCCESS;
  68. }
  69. DWORD _inline
  70. MemArrayPrevLoc(
  71. IN PARRAY Array,
  72. IN OUT PARRAY_LOCATION Location
  73. ) {
  74. AssertRet(Array && Location, ERROR_INVALID_PARAMETER);
  75. if( 0 == Array->nElements ) return ERROR_FILE_NOT_FOUND;
  76. if( ((LONG)(*Location)) - 1 < 0 ) return ERROR_FILE_NOT_FOUND;
  77. (*Location) --;
  78. return ERROR_SUCCESS;
  79. }
  80. DWORD _inline
  81. MemArrayLastLoc(
  82. IN PARRAY Array,
  83. IN OUT PARRAY_LOCATION Location
  84. ) {
  85. AssertRet(Array && Location, ERROR_INVALID_PARAMETER);
  86. if( 0 == Array->nElements ) return ERROR_FILE_NOT_FOUND;
  87. (*Location) = Array->nElements -1;
  88. return ERROR_SUCCESS;
  89. }
  90. DWORD _inline
  91. MemArrayGetElement(
  92. IN PARRAY Array,
  93. IN PARRAY_LOCATION Location,
  94. OUT LPVOID *Element
  95. ) {
  96. AssertRet(Array && Location && Element, ERROR_INVALID_PARAMETER);
  97. (*Element) = Array->Ptrs[*Location];
  98. return ERROR_SUCCESS;
  99. }
  100. DWORD _inline
  101. MemArraySetElement(
  102. IN OUT PARRAY Array,
  103. IN PARRAY_LOCATION Location,
  104. IN LPVOID Element
  105. ) {
  106. AssertRet(Array && Location, ERROR_INVALID_PARAMETER );
  107. Array->Ptrs[*Location] = Element;
  108. return ERROR_SUCCESS;
  109. }
  110. DWORD
  111. MemArrayAddElement(
  112. IN OUT PARRAY Array,
  113. IN LPVOID Element
  114. ) ;
  115. DWORD
  116. MemArrayInsElement(
  117. IN OUT PARRAY Array,
  118. IN PARRAY_LOCATION Location,
  119. IN LPVOID Element
  120. ) ;
  121. DWORD
  122. MemArrayDelElement(
  123. IN OUT PARRAY Array,
  124. IN PARRAY_LOCATION Location,
  125. IN LPVOID *Element
  126. ) ;
  127. DWORD _inline
  128. MemArrayAdjustLocation( // reset location to "next" after a delete
  129. IN PARRAY Array,
  130. IN OUT PARRAY_LOCATION Location
  131. ) {
  132. AssertRet(Location && Array, ERROR_INVALID_PARAMETER);
  133. if( *Location >= Array->nElements ) return ERROR_FILE_NOT_FOUND;
  134. return ERROR_SUCCESS;
  135. }
  136. DWORD _inline
  137. MemArrayRotateCyclical( // rotate forward/right cyclical
  138. IN PARRAY Array
  139. ) {
  140. LPVOID FirstPtr;
  141. AssertRet(Array, ERROR_INVALID_PARAMETER);
  142. if( Array->nElements < 2 ) return ERROR_SUCCESS;
  143. FirstPtr = Array->Ptrs[0];
  144. memcpy(Array->Ptrs, &Array->Ptrs[1], sizeof(Array->Ptrs[0])* (Array->nElements -1));
  145. Array->Ptrs[Array->nElements -1] = FirstPtr;
  146. return ERROR_SUCCESS;
  147. }
  148. //========================================================================
  149. // end of file
  150. //========================================================================