comctl32: Actually grow the array in DPA_Grow.

This commit is contained in:
Alexandre Julliard 2010-01-29 13:18:56 +01:00
parent 6bc1a359f8
commit 9e47c59427
2 changed files with 18 additions and 3 deletions

View file

@ -426,12 +426,27 @@ BOOL WINAPI DPA_Destroy (const HDPA hdpa)
*/
BOOL WINAPI DPA_Grow (HDPA hdpa, INT nGrow)
{
INT items;
TRACE("(%p %d)\n", hdpa, nGrow);
if (!hdpa)
return FALSE;
hdpa->nGrow = max(8, nGrow);
nGrow = max( 8, nGrow );
items = nGrow * (((hdpa->nMaxCount - 1) / nGrow) + 1);
if (items > hdpa->nMaxCount)
{
void *ptr;
if (hdpa->ptrs)
ptr = HeapReAlloc( hdpa->hHeap, HEAP_ZERO_MEMORY, hdpa->ptrs, items * sizeof(LPVOID) );
else
ptr = HeapAlloc( hdpa->hHeap, HEAP_ZERO_MEMORY, items * sizeof(LPVOID) );
if (!ptr) return FALSE;
hdpa->nMaxCount = items;
hdpa->ptrs = ptr;
}
hdpa->nGrow = nGrow;
return TRUE;
}

View file

@ -213,9 +213,9 @@ static void test_dpa(void)
dpa3 = pDPA_CreateEx(0, hHeap);
ok(dpa3 != NULL, "\n");
ret = pDPA_Grow(dpa3, si.dwPageSize + 1);
todo_wine ok(!ret && GetLastError() == ERROR_NOT_ENOUGH_MEMORY,
ok(!ret && GetLastError() == ERROR_NOT_ENOUGH_MEMORY,
"ret=%d error=%d\n", ret, GetLastError());
dpa = pDPA_Create(0);
ok(dpa != NULL, "\n");