{
DWORD bufferSize;
DWORD* newBuffer;
WCHAR* stringBuffer;
intlen;
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;
}
Generated on Sun May 27 2012 05:15:57 for ReactOS by
1.7.6.1
ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.