Commit 9e47c594 authored by Alexandre Julliard's avatar Alexandre Julliard

comctl32: Actually grow the array in DPA_Grow.

parent 6bc1a359
...@@ -426,12 +426,27 @@ BOOL WINAPI DPA_Destroy (const HDPA hdpa) ...@@ -426,12 +426,27 @@ BOOL WINAPI DPA_Destroy (const HDPA hdpa)
*/ */
BOOL WINAPI DPA_Grow (HDPA hdpa, INT nGrow) BOOL WINAPI DPA_Grow (HDPA hdpa, INT nGrow)
{ {
INT items;
TRACE("(%p %d)\n", hdpa, nGrow); TRACE("(%p %d)\n", hdpa, nGrow);
if (!hdpa) if (!hdpa)
return FALSE; 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; return TRUE;
} }
......
...@@ -213,9 +213,9 @@ static void test_dpa(void) ...@@ -213,9 +213,9 @@ static void test_dpa(void)
dpa3 = pDPA_CreateEx(0, hHeap); dpa3 = pDPA_CreateEx(0, hHeap);
ok(dpa3 != NULL, "\n"); ok(dpa3 != NULL, "\n");
ret = pDPA_Grow(dpa3, si.dwPageSize + 1); 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()); "ret=%d error=%d\n", ret, GetLastError());
dpa = pDPA_Create(0); dpa = pDPA_Create(0);
ok(dpa != NULL, "\n"); ok(dpa != NULL, "\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment