Array.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:20k
源码类别:

DVD

开发平台:

Others

  1. /****************************************************************************************
  2.  *  Copyright (c) 2002 ZORAN Corporation, All Rights Reserved
  3.  *  THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
  4.  *
  5.  *  File: $Workfile: Array.c $             
  6.  *
  7.  * Description: Implementation of a generic Array.
  8.  * ============
  9.  * 
  10.  * 
  11.  * Log:
  12.  * ====
  13.  * $Revision: 5 $
  14.  * Last Modified by $Author: Frankm $ at $Modtime: 03-04-17 15:33 $ 
  15.  ****************************************************************************************
  16.  * Updates:
  17.  ****************************************************************************************
  18.  * $Log: /SourceCode/I64_Common/I64_Reference/Playcore/DataStructures/Array.c $
  19.  * 
  20.  * 5     03-04-17 15:36 Frankm
  21.  * The Address doesn't add during the for loop.
  22.  * 
  23.  * 4     03-03-20 10:43 Jerryc
  24.  * support array with size > (WORD - 1)
  25.  * 
  26.  * 3     03-01-30 23:16 Leslie
  27.  * Add new function ArrayInitBound
  28.  * 
  29.  * 13    27/05/02 18:50 Nirm
  30.  * - Cleaned-up compilation-warnings.
  31.  * 
  32.  * 12    23/05/02 14:09 Ettim
  33.  * Adding support for an absolute 32 bit address on the scratch pad.
  34.  * 
  35.  * 11    23/04/02 9:28 Nirm
  36.  * - Added dependency in "Config.h".
  37.  * 
  38.  * 10    25/02/02 21:07 Nirm
  39.  * - Eliminated Array_freeExtra() - Cannot be accurately supported.
  40.  * 
  41.  * 9     21/02/02 14:11 Nirm
  42.  * Fixed a debugging message.
  43.  * 
  44.  * 8     10/02/02 13:59 Nirm
  45.  * Corrected Upper-Bound arithmetic.
  46.  * 
  47.  * 7     6/02/02 16:05 Nirm
  48.  * Fixed the return value of Array_getSize().
  49.  * 
  50.  * 6     4/02/02 12:53 Nirm
  51.  * Added Array_freeExtra().
  52.  * 
  53.  * 5     21/01/02 22:03 Nirm
  54.  * Fixed wrong offset in External-Memory accesses.
  55.  * 
  56.  * 4     17/01/02 20:46 Nirm
  57.  * Removed the byte-padding of each Element, to reduce memory wasting.
  58.  * 
  59.  * 3     9/01/02 14:48 Nirm
  60.  * Corrected Include-Paths.
  61.  * 
  62.  * 2     26/12/01 17:41 Nirm
  63.  * First working version.
  64.  * 
  65.  * 1     26/12/01 14:57 Nirm
  66.  ****************************************************************************************/
  67. /////////////////////////////////////////////////////////////////////////////
  68. // Array.c - Implementation of a generic Array, whose elements are structures
  69. //  of a configurable fixed size. 
  70. //  All elements reside in the External-Memory.
  71. //
  72. // Author: Nir Milstein
  73. #include "Config.h" // Global Configuration - do not remove!
  74. #ifdef _DEBUG
  75. #undef IFTRACE
  76. #define IFTRACE if (gTraceCore)
  77. #include "DebugDbgMain.h"
  78. #endif //_DEBUG
  79. #include "PlaycoreDataStructuresArray.h"
  80. #include "PlaycoreScPadScMgr.h"
  81. /////////////////////////////////////////////////////////////////////////////
  82. // Constants
  83. #if defined(MANUAL_DIRECTORY_EXPLORER)
  84. #define ARRAY_POOL_SIZE 6
  85. #elif defined(DVD_VR_SUPPORT)
  86. #define ARRAY_POOL_SIZE 8
  87. #else
  88. #define ARRAY_POOL_SIZE 5
  89. #endif
  90. #define FREE_MEMORY 0x01
  91. #define USE_EXTENDED_ADDRESS 0x02
  92. /////////////////////////////////////////////////////////////////////////////
  93. // Structures
  94. typedef struct Array_TAG 
  95. {
  96. UINT32 dwBaseAddress;
  97. UINT16 cbElementSize;
  98. UINT16 uCapacity;
  99. UINT16 uUpperBound;
  100. UINT8 ucFlags;
  101. } Array;
  102. #define NULL_ARRAY 0xFFFFFFFFUL
  103. /////////////////////////////////////////////////////////////////////////////
  104. // Globals
  105. static Array g_aArrayPool[ARRAY_POOL_SIZE];
  106. static BOOL g_bArrayPoolInitialized= FALSE;
  107. /////////////////////////////////////////////////////////////////////////////
  108. // Generic Array Interface Implementation
  109. /////////////////////////////////////////////////////////////////////////////
  110. // Array_construct()
  111. //
  112. // Description: Constructs a new Array.
  113. //
  114. // Input: i_uElementsCnt - The size of the Array to construct
  115. // i_cbElementSize - The size, in Bytes, of each Element of the 
  116. //   Array.
  117. // Output: None
  118. // In/Out: io_pExternalMemoryPoolAddress - Points to a WORD, which 
  119. // specifies an External-Memory address, from which to allocate
  120. // the Array. May be NULL.
  121. //
  122. // Return: A 32-bit DWORD, which is Handle to the newly constructed Array.
  123. // a NULL Handle is returned if the construction fails.
  124. //
  125. // Remarks:
  126. // - The Array-Handle returned must be saved by the user, and is required
  127. //   for any operation or query performed on this Array.
  128. // - If a NULL pointer to an External-Memory Pool Address is supplied,
  129. //   the memory for the Array is automatically allocated from the
  130. //   External-Memory by the Array constructor, and freed by the destructor.
  131. UINT32 Array_construct(UINT16 i_uElementsCnt, UINT16 i_cbElementSize,
  132.    WORD *io_pExternalMemoryPoolAddress)
  133. {
  134. UINT8  uArrayPoolSlot;
  135. UINT16 uArraySizeInContainers;
  136. Array *pNewArray= NULL;
  137. // Initialize the Array-Pool, if needed
  138. if (!g_bArrayPoolInitialized) {
  139. int i;
  140. memset(g_aArrayPool, 0, sizeof(g_aArrayPool));
  141. g_bArrayPoolInitialized= TRUE;
  142. //MikeX: Change the dwBaseAddress Null-Handler value
  143. for(i=0;i<ARRAY_POOL_SIZE;i++)
  144. g_aArrayPool[i].dwBaseAddress=NULL_ARRAY;
  145. }
  146. // Iterate over the Array-Pool, trying to find an available slot
  147. for (uArrayPoolSlot=0; uArrayPoolSlot < ARRAY_POOL_SIZE; uArrayPoolSlot++) {
  148. //if (0 == g_aArrayPool[uArrayPoolSlot].dwBaseAddress)
  149. if (NULL_ARRAY == g_aArrayPool[uArrayPoolSlot].dwBaseAddress)//MikeX: Change the dwBaseAddress Null-Handler value
  150. break;
  151. }
  152. // Check if an available slot was found
  153. if (ARRAY_POOL_SIZE == uArrayPoolSlot) {
  154. tr_printf(("WARNING: Array_construct() Failed [1]: The Array-Pool has been exhausted.n"));
  155. return (UINT32)NULL;
  156. }
  157. // Update the new Array
  158. pNewArray= &g_aArrayPool[uArrayPoolSlot];
  159. pNewArray->cbElementSize= i_cbElementSize;
  160. pNewArray->uCapacity= i_uElementsCnt;
  161. // Calculate the Array's size in External-Memory Containers
  162. uArraySizeInContainers= CONTAINER_COUNT(i_uElementsCnt * i_cbElementSize);
  163. // If needed, allocate External-Memory for the Array
  164. if (NULL == io_pExternalMemoryPoolAddress) {
  165. pNewArray->dwBaseAddress= (DWORD)sc_Malloc(uArraySizeInContainers);
  166. // Verify that the Array was properly allocated
  167. if ((DWORD)NULL_HANDLE == pNewArray->dwBaseAddress) {
  168. tr_printf(("WARNING: Array_construct() Failed [2]: Low system resources.n"));
  169. //pNewArray->dwBaseAddress= 0; //MikeX: Change the dwBaseAddress Null-Handler value
  170. pNewArray->dwBaseAddress= NULL_ARRAY;
  171. return (UINT32)NULL;
  172. }
  173. pNewArray->ucFlags |= FREE_MEMORY;
  174. }
  175. else {
  176. pNewArray->dwBaseAddress= (*io_pExternalMemoryPoolAddress);
  177. // Increment the Memory-Pool Address by the amount of Containers allocated for
  178. // the Array.
  179. *io_pExternalMemoryPoolAddress += uArraySizeInContainers;
  180. pNewArray->ucFlags &= (~FREE_MEMORY);
  181. }
  182. //not using extended address
  183. pNewArray->ucFlags &= (~USE_EXTENDED_ADDRESS);
  184. pNewArray->uUpperBound= 0;
  185. return (UINT32)pNewArray;
  186. }
  187. /////////////////////////////////////////////////////////////////////////////
  188. // Array_constructEx()
  189. //
  190. // Description: Constructs a new Array, using an Extended address.
  191. //
  192. // Input: i_uElementsCnt - The size of the Array to construct
  193. // i_cbElementSize - The size, in Bytes, of each Element of the 
  194. //   Array.
  195. // Output: None
  196. // In/Out: io_pExternalMemoryPoolAddress - Points to a DWORD, which 
  197. // specifies an External-Memory address, from which to allocate
  198. // the Array. May not be NULL.
  199. //
  200. // Return: A 32-bit DWORD, which is Handle to the newly constructed Array.
  201. // a NULL Handle is returned if the construction fails.
  202. //
  203. // Remarks:
  204. // - The Array-Handle returned must be saved by the user, and is required
  205. //   for any operation or query performed on this Array.
  206. UINT32 Array_constructEx(UINT16 i_uElementsCnt, UINT16 i_cbElementSize,
  207.  DWORD *io_pExternalMemoryPoolAddress)
  208. {
  209. UINT8  uArrayPoolSlot;
  210. UINT32 uArraySizeInContainers;
  211. Array *pNewArray= NULL;
  212. // Initialize the Array-Pool, if needed
  213. if (! g_bArrayPoolInitialized) {
  214. int i;
  215. memset(g_aArrayPool, 0, sizeof(g_aArrayPool));
  216. g_bArrayPoolInitialized= TRUE;
  217. //MikeX: Change the dwBaseAddress Null-Handler value
  218. for(i=0;i<ARRAY_POOL_SIZE;i++)
  219. g_aArrayPool[i].dwBaseAddress=NULL_ARRAY;
  220. }
  221. // Iterate over the Array-Pool, trying to find an available slot
  222. for (uArrayPoolSlot=0; uArrayPoolSlot < ARRAY_POOL_SIZE; uArrayPoolSlot++) {
  223. if (NULL_ARRAY == g_aArrayPool[uArrayPoolSlot].dwBaseAddress)//MikeX: Change the dwBaseAddress Null-Handler value
  224. break;
  225. }
  226. // Check if an available slot was found
  227. if (ARRAY_POOL_SIZE == uArrayPoolSlot) {
  228. tr_printf(("WARNING: Array_constructEx() Failed [1]: The Array-Pool has been exhausted.n"));
  229. return (UINT32)NULL;
  230. }
  231. // Update the new Array
  232. pNewArray= &g_aArrayPool[uArrayPoolSlot];
  233. pNewArray->cbElementSize= i_cbElementSize;
  234. pNewArray->uCapacity= i_uElementsCnt;
  235. // Calculate the Array's size in External-Memory Containers
  236.   uArraySizeInContainers= CONTAINER_COUNT((UINT32)i_uElementsCnt * (UINT32)i_cbElementSize);
  237. // memory address MUST be given
  238. if (NULL == io_pExternalMemoryPoolAddress) {
  239. #ifdef _DEBUG
  240. tr_printf(("WARNING: Array_constructEx() Failed [2]: Invalid memory address.n"));
  241. //pNewArray->dwBaseAddress= 0;
  242. pNewArray->dwBaseAddress= NULL_ARRAY;//MikeX: Change the dwBaseAddress Null-Handler value
  243. return (UINT32)NULL;
  244. #endif
  245. }
  246. else {
  247. pNewArray->dwBaseAddress= (*io_pExternalMemoryPoolAddress);
  248. // Increment the Memory-Pool Address by the amount of Containers allocated for
  249. // the Array.
  250. *io_pExternalMemoryPoolAddress += uArraySizeInContainers;
  251. pNewArray->ucFlags &= (~FREE_MEMORY);
  252. }
  253. //using extended address
  254. pNewArray->ucFlags |= USE_EXTENDED_ADDRESS;
  255. pNewArray->uUpperBound= 0;
  256. return (UINT32)pNewArray;
  257. }
  258. /////////////////////////////////////////////////////////////////////////////
  259. // Array_destruct()
  260. //
  261. // Description: Destructs an existing Array, that was previously created using
  262. // a call to Array_construct().
  263. //
  264. // Input: hArray - The Array-Handle associated with the Array to destruct.
  265. // Output: None
  266. // In/Out: None
  267. // Return: None
  268. //
  269. // Remarks:
  270. // If the External-Memory used for the Array was automatically allocated
  271. // by the constructor, then it is freed.
  272. // Otherwise, it is the user's responsibility to free any External-Memory 
  273. // Pool that was supplied to the constructor.
  274. void Array_destruct(UINT32 hArray)
  275. {
  276. Array *pArray= (Array *)hArray;
  277. // Verify validity of the supplied Array Handle
  278. if (NULL == pArray) {
  279. tr_printf(("FATAL: Array_destruct() Failed [1]: Invalid Array handle supplied.n"));
  280. return;
  281. }
  282. // Free the associated External-Memory, if it was allocated dynamically
  283. if (pArray->ucFlags & FREE_MEMORY) {
  284. sc_Free((WORD)pArray->dwBaseAddress, 
  285. CONTAINER_COUNT(pArray->uCapacity * pArray->cbElementSize));
  286. }
  287. // Free the Array-Pool slot
  288. pArray->dwBaseAddress= NULL_ARRAY;//MikeX: Change the dwBaseAddress Null-Handler value
  289. return;
  290. }
  291. /////////////////////////////////////////////////////////////////////////////
  292. // Array_freeExtra()
  293. //
  294. // Description: Frees any unused memory, provided that the array was
  295. // automatically allocated at construction time.
  296. //
  297. // Input: hArray - The Array-Handle associated with the Array to be
  298. //  shrinked.
  299. // Output: None
  300. // In/Out: None
  301. // Return: None
  302. //
  303. // Remarks: None
  304. #pragma argsused
  305. void Array_freeExtra(UINT32 hArray)
  306. {
  307. /*
  308. UINT16 uUpperBound;
  309. UINT16 uUnusedMemoryInCont;
  310. Array *pArray= (Array *)hArray;
  311. // Verify validity of the supplied Array Handle
  312. if (NULL == pArray) {
  313. tr_printf(("FATAL: Array_freeExtra() Failed [1]: Invalid Array handle supplied.n"));
  314. return;
  315. }
  316. // Verify that the Array was dynamically allocated
  317. if (0 == (pArray->uUpperBound & 0x8000)) {
  318. dbg_printf(("WARNING: Array_freeExtra() Failed [2]: Statically allocated Array.n"));
  319. return;
  320. }
  321. uUpperBound= (pArray->uUpperBound & 0x7FFF);
  322. // Check if there's anything to free
  323. if (pArray->uCapacity <= uUpperBound)
  324. return;
  325. // Compute the offset of the first unused Element
  326. uUpperBound= CONTAINER_COUNT(uUpperBound * pArray->cbElementSize);
  327. // Compute the amount of unused Memory
  328. uUnusedMemoryInCont= (CONTAINER_COUNT(pArray->uCapacity * pArray->cbElementSize) -
  329.   uUpperBound);
  330. // Actually free the unused memory
  331. uUnusedMemoryInCont= sc_Free((pArray->wBaseAddress + uUpperBound), uUnusedMemoryInCont);
  332. // Adjust the new Capacity
  333. pArray->uCapacity= ((uUnusedMemoryInCont * BYTE_PER_CONTAINER) / pArray->cbElementSize);
  334. */
  335. return;
  336. }
  337. /////////////////////////////////////////////////////////////////////////////
  338. // Array_getSize()
  339. //
  340. // Description: Returns the Size of an Array (the number of Elements it holds).
  341. //
  342. // Input: hArray - The Array-Handle associated with the Array whose size
  343. //  is requested.
  344. // Output: None
  345. // In/Out: None
  346. // Return: The size of the Array.
  347. //
  348. // Remarks:
  349. // The size of an Array was determined during its construction, and cannot
  350. // be changed.
  351. UINT16 Array_getSize(UINT32 hArray)
  352. {
  353. Array *pArray= (Array *)hArray;
  354. // Verify validity of the supplied Array Handle
  355. if (NULL == pArray) {
  356. tr_printf(("FATAL: Array_getSize() Failed [1]: Invalid Array handle supplied.n"));
  357. return 0;
  358. }
  359. // Return the Array's size
  360. //return (pArray->uUpperBound & 0x7FFF);
  361. return (pArray->uUpperBound);
  362. }
  363. void ArrayInitBound(UINT32 hArray,UINT16 num)
  364. {
  365. Array *pArray= (Array *)hArray;
  366. pArray->uUpperBound = num;
  367. }
  368. /////////////////////////////////////////////////////////////////////////////
  369. // Array_clear()
  370. //
  371. // Description: Clears the contents of an Array to Zero.
  372. //
  373. // Input: hArray - The Array-Handle associated with the Array to clear.
  374. // Output: None
  375. // In/Out: None
  376. // Return: None
  377. //
  378. // Remarks:
  379. // This method clears an Array's contents to Zero.
  380. void Array_clear(UINT32 hArray)
  381. {
  382. UINT16 uTotalContainersCnt;
  383. Array *pArray= (Array *)hArray;
  384. Sc_cont scContainer;
  385.        UINT32 dwAddress = pArray->dwBaseAddress;
  386.    
  387. // Verify validity of the supplied Array Handle
  388. if (NULL == pArray) {
  389. tr_printf(("FATAL: Array_clear() Failed [1]: Invalid Array handle supplied.n"));
  390. return;
  391. }
  392. memset(&scContainer, 0, sizeof(scContainer));
  393. // Calculate the total number of External-Memory containers that the Array occupies
  394. uTotalContainersCnt= CONTAINER_COUNT(pArray->uCapacity * pArray->cbElementSize);
  395.              
  396. // Clear the associated External-Memory
  397. for (; uTotalContainersCnt > 0; uTotalContainersCnt--)
  398. {
  399. if (pArray->ucFlags & USE_EXTENDED_ADDRESS)
  400. sc_Write32(dwAddress++, 1, &scContainer);
  401. else
  402. sc_Write((WORD)dwAddress++, 1, &scContainer);
  403. }
  404.        
  405. return;
  406. }
  407. /////////////////////////////////////////////////////////////////////////////
  408. // Array_getAt()
  409. //
  410. // Description: Retrieves an Array Element at a specific position.
  411. //
  412. // Input: hArray - The Array-Handle associated with the Array to query.
  413. // uIndex - The Index of the requested Element.
  414. // Output: o_pElementContainer - Points to a buffer to receive the requested
  415. //   Element upon return.
  416. // In/Out: None
  417. // Return: TRUE if the requested Element was successfully retrieved;
  418. // FALSE otherwise.
  419. //
  420. // Remarks:
  421. // - This method may fail if the supplied Array-Handle is invalid, or if the
  422. //   supplied Index is out of the valid range.
  423. // - In case of failure, the supplied container is not modified.
  424. // - The supplied container must be at large enough to accomodate for the
  425. //   Element; it should be at least the size of a single Element, as reported
  426. //   during construction of the Array.
  427. BOOL Array_getAt(UINT32 hArray, UINT16 uIndex, BYTE *o_pElementContainer)
  428. {
  429. DWORD dwElementAddress;
  430. WORD wElementOffset;
  431. Array *pArray= (Array *)hArray;
  432. // Verify validity of the supplied Array Handle
  433. if (NULL == pArray) {
  434. tr_printf(("FATAL: Array_getAt() Failed [1]: Invalid Array handle supplied.n"));
  435. return FALSE;
  436. }
  437. // Check range validity
  438. if (uIndex >= pArray->uUpperBound) {
  439. tr_printf(("WARNING: Array_getAt() Failed [2]: Supplied Index out of range.n"));
  440. return FALSE;
  441. }
  442. // Calculate the Address of the requested Element, and the Byte-Offset from that
  443. // Address.
  444. dwElementAddress= (pArray->dwBaseAddress + (DWORD)CONTAINER_NORM((DWORD)uIndex * pArray->cbElementSize));
  445. wElementOffset= (WORD)CONTAINER_MOD((DWORD)uIndex * pArray->cbElementSize);
  446. // Retrieve the Element
  447. if (pArray->ucFlags & USE_EXTENDED_ADDRESS)
  448. sc_GetBytes32(dwElementAddress, wElementOffset, pArray->cbElementSize, o_pElementContainer);
  449. else
  450. sc_GetBytes((WORD)dwElementAddress, wElementOffset, pArray->cbElementSize, o_pElementContainer);
  451. return TRUE;
  452. }
  453. /////////////////////////////////////////////////////////////////////////////
  454. // Array_setAt()
  455. //
  456. // Description: Assigns an Array Element at a specific position.
  457. //
  458. // Input: hArray - The Array-Handle associated with the Array to assign.
  459. // uIndex - The Index of the Element to be assigned.
  460. // i_pElement - Points to a constant buffer, whose contents is
  461. //  the Element to assign.
  462. // Output: None
  463. // In/Out: None
  464. // Return: TRUE if the requested Element was successfully assigned;
  465. // FALSE otherwise.
  466. //
  467. // Remarks:
  468. // - This method may fail if the supplied Array-Handle is invalid, or if the
  469. //   supplied Index is out of the valid range.
  470. // - In case of failure, no Array element is assigned.
  471. // - The method copies an amount of Bytes equal to the Element-size, as
  472. //   reported during construction of the Array.
  473. BOOL Array_setAt(UINT32 hArray, UINT16 uIndex, const BYTE *i_pElement)
  474. {
  475. DWORD dwElementAddress;
  476. WORD wElementOffset;
  477. Array *pArray= (Array *)hArray;
  478. // Verify validity of the supplied Array Handle
  479. if (NULL == pArray) {
  480. tr_printf(("FATAL: Array_setAt() Failed [1]: Invalid Array handle supplied.n"));
  481. return FALSE;
  482. }
  483. // Check range validity
  484. if (uIndex >= pArray->uCapacity) {
  485. tr_printf(("WARNING: Array_setAt() Failed [2]: Supplied Index out of range.n"));
  486. return FALSE;
  487. }
  488. // Calculate the Address of the requested Element
  489. dwElementAddress= (pArray->dwBaseAddress + (DWORD)CONTAINER_NORM((DWORD)uIndex * pArray->cbElementSize));
  490. wElementOffset= (WORD)CONTAINER_MOD((DWORD)uIndex * pArray->cbElementSize);
  491. // Store the Element
  492. if (pArray->ucFlags & USE_EXTENDED_ADDRESS)
  493. sc_SetBytes32(dwElementAddress, wElementOffset, pArray->cbElementSize, (BYTE*)i_pElement);
  494. else
  495. sc_SetBytes((WORD)dwElementAddress, wElementOffset, pArray->cbElementSize, (BYTE*)i_pElement);
  496. // Update the Upper-Bound, if necessary
  497. if (uIndex >= pArray->uUpperBound) {
  498. pArray->uUpperBound= (uIndex+1);
  499. }
  500. return TRUE;
  501. }
  502. #ifdef DVD_VR_SUPPORT
  503. /////////////////////////////////////////////////////////////////////////////
  504. // Generic Array Interface Implementation
  505. /////////////////////////////////////////////////////////////////////////////
  506. // Array_construct()
  507. //
  508. // Description: Reconstructs a Array.
  509. //
  510. // Input: hArray - The Array-Handle associated with the Array to assign.
  511. // i_uNewElementsCnt - The new size of array to construct.
  512. // Output: None
  513. //
  514. // Return: A 32-bit DWORD, which is the size of the new array.
  515. //
  516. // Remarks:
  517. // - Change the array size. Only for extend memory.
  518. UINT32 Array_reconstruct(UINT32 hArray, UINT16 i_uNewElementsCnt)
  519. {
  520. Array *pArray= (Array *)hArray;
  521. if (NULL == pArray) {
  522. tr_printf(("FATAL: Array_reconstruct() Failed [1]: Invalid Array handle supplied.n"));
  523. return FALSE;
  524. }
  525. pArray->uCapacity = i_uNewElementsCnt;
  526. return (DWORD) CONTAINER_COUNT((UINT32)pArray->uCapacity * (UINT32)pArray->cbElementSize);
  527. }
  528. UINT16 Array_getCapacity(UINT32 hArray)
  529. {
  530. Array *pArray= (Array *)hArray;
  531. // Verify validity of the supplied Array Handle
  532. if (NULL == pArray) {
  533. tr_printf(("FATAL: Array_getCapacity() Failed [1]: Invalid Array handle supplied.n"));
  534. return 0;
  535. }
  536. return (pArray->uCapacity);
  537. }
  538. #endif//DVD_VR_SUPPORT