Resize dynamic pointer array more carefully when adding new entries.

This commit is contained in:
Paul Rupe 2002-09-25 03:19:24 +00:00 committed by Alexandre Julliard
parent 80be53efee
commit 2fbe9cf2b7
1 changed files with 3 additions and 6 deletions

View File

@ -1957,11 +1957,7 @@ DPA_SetPtr (const HDPA hdpa, INT i, LPVOID p)
if (hdpa->nItemCount <= i) {
/* within the old array */
if (hdpa->nMaxCount > i) {
/* within the allocated space, set a new boundary */
hdpa->nItemCount = i+1;
}
else {
if (hdpa->nMaxCount <= i) {
/* resize the block of memory */
INT nNewItems =
hdpa->nGrow * ((INT)(((i+1) - 1) / hdpa->nGrow) + 1);
@ -1972,9 +1968,10 @@ DPA_SetPtr (const HDPA hdpa, INT i, LPVOID p)
if (!lpTemp)
return FALSE;
hdpa->nItemCount = nNewItems;
hdpa->nMaxCount = nNewItems;
hdpa->ptrs = lpTemp;
}
hdpa->nItemCount = i+1;
}
/* put the new entry in */