Fix some DPA functions so they pass the new tests.
This commit is contained in:
parent
9f4c67d50d
commit
7dde735180
|
@ -540,15 +540,16 @@ INT WINAPI DPA_InsertPtr (const HDPA hdpa, INT i, LPVOID p)
|
|||
|
||||
if (!hdpa || i < 0) return -1;
|
||||
|
||||
if (i >= 0x7fff)
|
||||
i = hdpa->nItemCount;
|
||||
|
||||
if (i >= hdpa->nItemCount)
|
||||
return DPA_SetPtr(hdpa, i, p) ? i : -1;
|
||||
/* append item if index is out of bounds */
|
||||
i = min(hdpa->nItemCount, i);
|
||||
|
||||
/* create empty spot at the end */
|
||||
if (!DPA_SetPtr(hdpa, hdpa->nItemCount, 0)) return -1;
|
||||
memmove (hdpa->ptrs + i + 1, hdpa->ptrs + i, (hdpa->nItemCount - i - 1) * sizeof(LPVOID));
|
||||
|
||||
if (i != hdpa->nItemCount - 1)
|
||||
memmove (hdpa->ptrs + i + 1, hdpa->ptrs + i,
|
||||
(hdpa->nItemCount - i - 1) * sizeof(LPVOID));
|
||||
|
||||
hdpa->ptrs[i] = p;
|
||||
return i;
|
||||
}
|
||||
|
@ -574,7 +575,7 @@ BOOL WINAPI DPA_SetPtr (const HDPA hdpa, INT i, LPVOID p)
|
|||
|
||||
TRACE("(%p %d %p)\n", hdpa, i, p);
|
||||
|
||||
if (!hdpa || i < 0 || i > 0x7fff)
|
||||
if (!hdpa || i < 0)
|
||||
return FALSE;
|
||||
|
||||
if (hdpa->nItemCount <= i) {
|
||||
|
@ -824,13 +825,7 @@ INT WINAPI DPA_Search (const HDPA hdpa, LPVOID pFind, INT nStart,
|
|||
}
|
||||
}
|
||||
|
||||
if (uOptions & DPAS_INSERTBEFORE) {
|
||||
if (r == -1) r = 0;
|
||||
TRACE("-- ret=%d\n", r);
|
||||
return r;
|
||||
}
|
||||
|
||||
if (uOptions & DPAS_INSERTAFTER) {
|
||||
if (uOptions & (DPAS_INSERTBEFORE | DPAS_INSERTAFTER)) {
|
||||
TRACE("-- ret=%d\n", l);
|
||||
return l;
|
||||
}
|
||||
|
|
|
@ -229,12 +229,12 @@ static void test_dpa(void)
|
|||
ok(ret == 3, "ret=%d\n", ret);
|
||||
/* Append item using out of bound index */
|
||||
ret = pDPA_InsertPtr(dpa, 5, (PVOID)2);
|
||||
todo_wine ok(ret == 4, "ret=%d\n", ret);
|
||||
ok(ret == 4, "ret=%d\n", ret);
|
||||
/* Append item using DPA_APPEND */
|
||||
ret = pDPA_InsertPtr(dpa, DPA_APPEND, (PVOID)4);
|
||||
todo_wine ok(ret == 5, "ret=%d\n", ret);
|
||||
ok(ret == 5, "ret=%d\n", ret);
|
||||
|
||||
todo_wine ok(CheckDPA(dpa, 0x516324, &dw), "dw=0x%lx\n", dw);
|
||||
ok(CheckDPA(dpa, 0x516324, &dw), "dw=0x%lx\n", dw);
|
||||
|
||||
for(i = 1; i <= 6; i++)
|
||||
{
|
||||
|
@ -306,7 +306,7 @@ static void test_dpa(void)
|
|||
/* DPAS_INSERTBEFORE works just like DPAS_INSERTAFTER */
|
||||
i = pDPA_Search(dpa, (PVOID)3, 0,
|
||||
CB_CmpLT, 0xdeadbeef, DPAS_SORTED|DPAS_INSERTBEFORE);
|
||||
todo_wine ok(i == 2, "i=%d\n", i);
|
||||
ok(i == 2, "i=%d\n", i);
|
||||
|
||||
/* Re-insert the item */
|
||||
ret = pDPA_InsertPtr(dpa, 2, (PVOID)3);
|
||||
|
@ -355,9 +355,9 @@ static void test_dpa(void)
|
|||
}
|
||||
|
||||
/* Setting item with huge index should work */
|
||||
todo_wine ok(pDPA_SetPtr(dpa2, 0x12345, (PVOID)0xdeadbeef), "\n");
|
||||
ok(pDPA_SetPtr(dpa2, 0x12345, (PVOID)0xdeadbeef), "\n");
|
||||
ret = pDPA_GetPtrIndex(dpa2, (PVOID)0xdeadbeef);
|
||||
todo_wine ok(ret == 0x12345, "ret=%d\n", ret);
|
||||
ok(ret == 0x12345, "ret=%d\n", ret);
|
||||
|
||||
pDPA_DeleteAllPtrs(dpa2);
|
||||
ok(CheckDPA(dpa2, 0, &dw2), "dw2=0x%lx\n", dw2);
|
||||
|
|
Loading…
Reference in New Issue