ReactOS 0.4.16-dev-981-g80eb313
heap.c
Go to the documentation of this file.
1/*
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17/*
18 * COPYRIGHT: See COPYING in the top level directory
19 * PROJECT: ReactOS GDI32
20 * PURPOSE:
21 * FILE: win32ss/gdi/gdi32/misc/heap.c
22 * PROGRAMER:
23 * REVISION HISTORY:
24 * NOTES:
25 */
26
27#include <precomp.h>
28#include <debug.h>
29
30// global variables in a dll are process-global
32
35{
36 ULONG len;
38
39 *ppszW = NULL;
40 if ( !lpszA )
41 return STATUS_SUCCESS;
42 len = lstrlenA(lpszA);
43
44 *ppszW = HEAP_alloc ( (len+1) * sizeof(WCHAR) );
45 if ( !*ppszW )
46 return STATUS_NO_MEMORY;
47 Status = RtlMultiByteToUnicodeN ( *ppszW, len*sizeof(WCHAR), NULL, (PCHAR)lpszA, len );
48 (*ppszW)[len] = UNICODE_NULL;
49 return Status;
50}
51
54 _In_ PCSTR lpszA,
55 _In_ PWSTR pszStaticBuff,
56 _In_ SIZE_T cchStaticBuff)
57{
58 if (!lpszA)
59 return NULL;
60
61 SIZE_T size = strlen(lpszA) + 1;
62 PWSTR pszW = (size < cchStaticBuff) ? pszStaticBuff : HEAP_alloc(size * sizeof(WCHAR));
63 if (!pszW)
64 return NULL;
65
66 RtlMultiByteToUnicodeN(pszW, size * sizeof(WCHAR), NULL, lpszA, size);
67 return pszW;
68}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define NULL
Definition: types.h:112
Status
Definition: gdiplustypes.h:25
GLsizeiptr size
Definition: glext.h:5919
GLenum GLsizei len
Definition: glext.h:6722
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
_Use_decl_annotations_ NTSTATUS NTAPI RtlMultiByteToUnicodeN(_Out_ PWCH UnicodeString, _In_ ULONG UnicodeSize, _Out_opt_ PULONG ResultSize, _In_ PCCH MbString, _In_ ULONG MbSize)
Definition: nlsboot.c:62
#define _Outptr_
Definition: no_sal2.h:262
#define _In_
Definition: no_sal2.h:158
#define FASTCALL
Definition: nt_native.h:50
#define UNICODE_NULL
#define STATUS_SUCCESS
Definition: shellext.h:65
uint16_t * PWSTR
Definition: typedefs.h:56
ULONG_PTR SIZE_T
Definition: typedefs.h:80
const char * PCSTR
Definition: typedefs.h:52
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
PWSTR FASTCALL HEAP_strdupA2W_buf(_In_ PCSTR lpszA, _In_ PWSTR pszStaticBuff, _In_ SIZE_T cchStaticBuff)
Definition: heap.c:53
HANDLE hProcessHeap
Definition: heap.c:31
NTSTATUS FASTCALL HEAP_strdupA2W(_Outptr_ PWSTR *ppszW, _In_ PCSTR lpszA)
Definition: heap.c:34
__wchar_t WCHAR
Definition: xmlstorage.h:180