Your implementation would either cause a memory leak or making the caller responsive for freeing the memory which was allocated by your function, which is always a really faulty and bad pattern. You should better return an object caring for its own memory as std::wstring does:
inline std::wstring a2w(LPCSTR psz, UINT codepage)
{
if (!psz || *psz == 0)
return std::wstring();
int nLen = int(strlen(psz));
int resultChars = ::MultiByteToWideChar(codepage, 0, psz, nLen, nullptr, 0);
std::wstring result(resultChars, (wchar_t)0);
::MultiByteToWideChar(codepage, 0, psz, nLen, &result[0], resultChars);
return result;
}