Module: wine Branch: master Commit: 9e47c59427d5c16cad90d187efd9765f8ee0d90e URL: http://source.winehq.org/git/wine.git/?a=commit;h=9e47c59427d5c16cad90d187ef...
Author: Alexandre Julliard julliard@winehq.org Date: Fri Jan 29 13:18:56 2010 +0100
comctl32: Actually grow the array in DPA_Grow.
---
dlls/comctl32/dpa.c | 17 ++++++++++++++++- dlls/comctl32/tests/dpa.c | 4 ++-- 2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/dlls/comctl32/dpa.c b/dlls/comctl32/dpa.c index e3c03c8..9682344 100644 --- a/dlls/comctl32/dpa.c +++ b/dlls/comctl32/dpa.c @@ -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; } diff --git a/dlls/comctl32/tests/dpa.c b/dlls/comctl32/tests/dpa.c index 5fb11e3..419c1b1 100644 --- a/dlls/comctl32/tests/dpa.c +++ b/dlls/comctl32/tests/dpa.c @@ -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");