oleaut32: Alignment fixes for safearrays.
This commit is contained in:
parent
74b63d5e0d
commit
17ec77f19e
|
@ -164,6 +164,8 @@ static void test_marshal_LPSAFEARRAY(void)
|
|||
*(DWORD *)lpsa->pvData = 0xcafebabe;
|
||||
|
||||
lpsa->cLocks = 7;
|
||||
size = LPSAFEARRAY_UserSize(&umcb.Flags, 1, &lpsa);
|
||||
ok(size == 68, "size should be 68 bytes, not %ld\n", size);
|
||||
size = LPSAFEARRAY_UserSize(&umcb.Flags, 0, &lpsa);
|
||||
ok(size == 64, "size should be 64 bytes, not %ld\n", size);
|
||||
buffer = (unsigned char *)HeapAlloc(GetProcessHeap(), 0, size);
|
||||
|
@ -196,6 +198,25 @@ static void test_marshal_LPSAFEARRAY(void)
|
|||
LPSAFEARRAY_UserFree(&umcb.Flags, &lpsa2);
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, buffer);
|
||||
|
||||
sab.lLbound = 5;
|
||||
sab.cElements = 10;
|
||||
|
||||
lpsa = SafeArrayCreate(VT_R8, 1, &sab);
|
||||
*(double *)lpsa->pvData = 3.1415;
|
||||
|
||||
lpsa->cLocks = 7;
|
||||
size = LPSAFEARRAY_UserSize(&umcb.Flags, 1, &lpsa);
|
||||
ok(size == 128, "size should be 128 bytes, not %ld\n", size);
|
||||
size = LPSAFEARRAY_UserSize(&umcb.Flags, 0, &lpsa);
|
||||
ok(size == 128, "size should be 128 bytes, not %ld\n", size);
|
||||
buffer = (unsigned char *)HeapAlloc(GetProcessHeap(), 0, size);
|
||||
LPSAFEARRAY_UserMarshal(&umcb.Flags, buffer, &lpsa);
|
||||
|
||||
check_safearray(buffer, lpsa);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, buffer);
|
||||
SafeArrayDestroy(lpsa);
|
||||
}
|
||||
|
||||
static void check_bstr(void *buffer, BSTR b)
|
||||
|
|
|
@ -662,6 +662,7 @@ unsigned long WINAPI LPSAFEARRAY_UserSize(unsigned long *pFlags, unsigned long S
|
|||
|
||||
TRACE("("); dump_user_flags(pFlags); TRACE(", %ld, %p\n", StartingSize, *ppsa);
|
||||
|
||||
ALIGN_LENGTH(size, 3);
|
||||
size += sizeof(ULONG_PTR);
|
||||
if (*ppsa)
|
||||
{
|
||||
|
@ -726,10 +727,12 @@ unsigned long WINAPI LPSAFEARRAY_UserSize(unsigned long *pFlags, unsigned long S
|
|||
}
|
||||
break;
|
||||
}
|
||||
case SF_I8:
|
||||
ALIGN_LENGTH(size, 7);
|
||||
/* fallthrough */
|
||||
case SF_I1:
|
||||
case SF_I2:
|
||||
case SF_I4:
|
||||
case SF_I8:
|
||||
size += ulCellCount * psa->cbElements;
|
||||
break;
|
||||
default:
|
||||
|
@ -747,6 +750,7 @@ unsigned char * WINAPI LPSAFEARRAY_UserMarshal(unsigned long *pFlags, unsigned c
|
|||
|
||||
TRACE("("); dump_user_flags(pFlags); TRACE(", %p, &%p\n", Buffer, *ppsa);
|
||||
|
||||
ALIGN_POINTER(Buffer, 3);
|
||||
*(ULONG_PTR *)Buffer = *ppsa ? TRUE : FALSE;
|
||||
Buffer += sizeof(ULONG_PTR);
|
||||
if (*ppsa)
|
||||
|
@ -836,10 +840,13 @@ unsigned char * WINAPI LPSAFEARRAY_UserMarshal(unsigned long *pFlags, unsigned c
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SF_I8:
|
||||
ALIGN_POINTER(Buffer, 7);
|
||||
/* fallthrough */
|
||||
case SF_I1:
|
||||
case SF_I2:
|
||||
case SF_I4:
|
||||
case SF_I8:
|
||||
/* Just copy the data over */
|
||||
memcpy(Buffer, psa->pvData, ulCellCount * psa->cbElements);
|
||||
Buffer += ulCellCount * psa->cbElements;
|
||||
|
@ -871,6 +878,7 @@ unsigned char * WINAPI LPSAFEARRAY_UserUnmarshal(unsigned long *pFlags, unsigned
|
|||
|
||||
TRACE("("); dump_user_flags(pFlags); TRACE(", %p, %p\n", Buffer, ppsa);
|
||||
|
||||
ALIGN_POINTER(Buffer, 3);
|
||||
ptr = *(ULONG_PTR *)Buffer;
|
||||
Buffer += sizeof(ULONG_PTR);
|
||||
|
||||
|
@ -964,10 +972,13 @@ unsigned char * WINAPI LPSAFEARRAY_UserUnmarshal(unsigned long *pFlags, unsigned
|
|||
|
||||
break;
|
||||
}
|
||||
|
||||
case SF_I8:
|
||||
ALIGN_POINTER(Buffer, 7);
|
||||
/* fallthrough */
|
||||
case SF_I1:
|
||||
case SF_I2:
|
||||
case SF_I4:
|
||||
case SF_I8:
|
||||
/* Just copy the data over */
|
||||
memcpy((*ppsa)->pvData, Buffer, cell_count * (*ppsa)->cbElements);
|
||||
Buffer += cell_count * (*ppsa)->cbElements;
|
||||
|
|
Loading…
Reference in New Issue