Commit 1eda4ac4 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

ole32: Forward BSTR functions to oleaut32.

parent 674b9b9c
MODULE = ole32.dll MODULE = ole32.dll
IMPORTLIB = ole32 IMPORTLIB = ole32
IMPORTS = uuid advapi32 user32 gdi32 rpcrt4 IMPORTS = uuid advapi32 user32 gdi32 rpcrt4
DELAYIMPORTS = oleaut32
EXTRADEFS = -D_OLE32_ -DCOM_NO_WINDOWS_H \ EXTRADEFS = -D_OLE32_ -DCOM_NO_WINDOWS_H \
-DENTRY_PREFIX=OLE32_ -DPROXY_CLSID=CLSID_PSFactoryBuffer -DWINE_REGISTER_DLL -DENTRY_PREFIX=OLE32_ -DPROXY_CLSID=CLSID_PSFactoryBuffer -DWINE_REGISTER_DLL
......
...@@ -2816,86 +2816,22 @@ static void OLE_FreeClipDataArray(ULONG count, CLIPDATA * pClipDataArray) ...@@ -2816,86 +2816,22 @@ static void OLE_FreeClipDataArray(ULONG count, CLIPDATA * pClipDataArray)
/*********************************************************************** /***********************************************************************
* PropSysAllocString [OLE32.@] * PropSysAllocString [OLE32.@]
* NOTES: * NOTES
* Basically a copy of SysAllocStringLen. * Forward to oleaut32.
*/ */
BSTR WINAPI PropSysAllocString(LPCOLESTR str) BSTR WINAPI PropSysAllocString(LPCOLESTR str)
{ {
DWORD bufferSize; return SysAllocString(str);
DWORD* newBuffer;
WCHAR* stringBuffer;
int len;
if (!str) return 0;
len = lstrlenW(str);
/*
* Find the length of the buffer passed-in, in bytes.
*/
bufferSize = len * sizeof (WCHAR);
/*
* Allocate a new buffer to hold the string.
* Don't forget to keep an empty spot at the beginning of the
* buffer for the character count and an extra character at the
* end for the NULL.
*/
newBuffer = HeapAlloc(GetProcessHeap(), 0,
bufferSize + sizeof(WCHAR) + sizeof(DWORD));
/*
* If the memory allocation failed, return a null pointer.
*/
if (newBuffer==0)
return 0;
/*
* Copy the length of the string in the placeholder.
*/
*newBuffer = bufferSize;
/*
* Skip the byte count.
*/
newBuffer++;
memcpy(newBuffer, str, bufferSize);
/*
* Make sure that there is a nul character at the end of the
* string.
*/
stringBuffer = (WCHAR*)newBuffer;
stringBuffer[len] = '\0';
return stringBuffer;
} }
/*********************************************************************** /***********************************************************************
* PropSysFreeString [OLE32.@] * PropSysFreeString [OLE32.@]
* NOTES * NOTES
* Copy of SysFreeString. * Forward to oleaut32.
*/ */
void WINAPI PropSysFreeString(LPOLESTR str) void WINAPI PropSysFreeString(LPOLESTR str)
{ {
DWORD* bufferPointer; SysFreeString(str);
/* NULL is a valid parameter */
if(!str) return;
/*
* We have to be careful when we free a BSTR pointer, it points to
* the beginning of the string but it skips the byte count contained
* before the string.
*/
bufferPointer = (DWORD*)str;
bufferPointer--;
/*
* Free the memory from its "real" origin.
*/
HeapFree(GetProcessHeap(), 0, bufferPointer);
} }
/****************************************************************************** /******************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment