NT4/private/ole32/com/util/utils.cxx
2020-09-30 17:12:29 +02:00

45 lines
737 B
C++

/*++
Copyright (c) 1992 Microsoft Corporation
Module Name:
utils.cpp
Abstract:
This module contains the code for the utility routines
Author:
Srini Koppolu (srinik) 02-Mar-1992
Revision History:
Erik Gavriluk (erikgav) 31-Dec-1993 Chicago port
--*/
#include <ole2int.h>
#pragma SEG(UtDupString)
// copies string using the TASK allocator; returns NULL on out of memory
FARINTERNAL_(LPWSTR) UtDupString(LPCWSTR lpszIn)
{
LPWSTR lpszOut = NULL;
IMalloc FAR* pMalloc;
if (CoGetMalloc(MEMCTX_TASK, &pMalloc) == S_OK) {
if ((lpszOut =
(LPWSTR)pMalloc->Alloc(
(lstrlenW(lpszIn)+1) * sizeof(WCHAR))) != NULL)
lstrcpyW(lpszOut, lpszIn);
pMalloc->Release();
}
return lpszOut;
}