Module: wine Branch: stable Commit: 47d2d8213ef06f21e1a1edd5cdfe3ff9793bf0a7 URL: http://source.winehq.org/git/wine.git/?a=commit;h=47d2d8213ef06f21e1a1edd5cd...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Tue Jan 12 11:49:30 2016 +0300
ole2disp: Implement SafeArrayAllocData().
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org (cherry picked from commit beceaa82ca28b99ef49a3b34f691ff234f001344) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
dlls/ole2disp.dll16/ole2disp.c | 34 +++++++++++++++++++++++++++++++++ dlls/ole2disp.dll16/ole2disp.dll16.spec | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/dlls/ole2disp.dll16/ole2disp.c b/dlls/ole2disp.dll16/ole2disp.c index 539b515..5831d86 100644 --- a/dlls/ole2disp.dll16/ole2disp.c +++ b/dlls/ole2disp.dll16/ole2disp.c @@ -72,6 +72,23 @@ static void safearray_free(SEGPTR ptr) WOWGlobalUnlockFree16(ptr); }
+static ULONG safearray_getcellcount(const SAFEARRAY16 *sa) +{ + const SAFEARRAYBOUND16 *sab = sa->rgsabound; + USHORT count = sa->cDims; + ULONG cells = 1; + + while (count--) + { + if (!sab->cElements) + return 0; + cells *= sab->cElements; + sab++; + } + + return cells; +} + /****************************************************************************** * SafeArrayAllocDescriptor [OLE2DISP.38] */ @@ -96,6 +113,23 @@ HRESULT WINAPI SafeArrayAllocDescriptor16(UINT16 dims, SEGPTR *ret) }
/****************************************************************************** + * SafeArrayAllocData [OLE2DISP.39] + */ +HRESULT WINAPI SafeArrayAllocData16(SAFEARRAY16 *sa) +{ + ULONG size; + + TRACE("%p\n", sa); + + if (!sa) + return E_INVALIDARG16; + + size = safearray_getcellcount(sa); + sa->pvData = safearray_alloc(size * sa->cbElements); + return sa->pvData ? S_OK : E_OUTOFMEMORY16; +} + +/****************************************************************************** * SafeArrayDestroyDescriptor [OLE2DISP.40] */ HRESULT WINAPI SafeArrayDestroyDescriptor16(SEGPTR s) diff --git a/dlls/ole2disp.dll16/ole2disp.dll16.spec b/dlls/ole2disp.dll16/ole2disp.dll16.spec index 997de31..919583d 100644 --- a/dlls/ole2disp.dll16/ole2disp.dll16.spec +++ b/dlls/ole2disp.dll16/ole2disp.dll16.spec @@ -36,7 +36,7 @@ 36 stub REVOKEACTIVEOBJECT 37 stub GETACTIVEOBJECT 38 pascal SafeArrayAllocDescriptor(word ptr) SafeArrayAllocDescriptor16 -39 stub SAFEARRAYALLOCDATA +39 pascal SafeArrayAllocData(ptr) SafeArrayAllocData16 40 pascal SafeArrayDestroyDescriptor(segptr) SafeArrayDestroyDescriptor16 41 stub SAFEARRAYDESTROYDATA 42 stub SAFEARRAYREDIM