|
|
1.1 root 1: /***************************** Module Header *******************************
2: * str2heap.c
3: * Function to add a string to the heap storage. Requires the string
4: * and the heap handle; returns the address where the string is
5: * placed. The string is WIDE!!
6: *
7: * RETURNS:
8: * The address to where the string has been copied, or 0 if the
9: * heap allocation fails.
10: *
11: * HISTORY:
12: * 11:28 on Wed 26 Feb 1992 -by- Lindsay Harris [lindsayh]
13: * Copied from str2heap.c & converted.
14: *
15: * Copyright (C) 1990 - 1993 Microsoft Corporation
16: *
17: *************************************************************************/
18:
19: #include <string.h>
20: #include <stddef.h>
21: #include <windows.h>
22: #include "libproto.h"
23:
24:
25: PWSTR
26: WstrToHeap( hheap, pwstr )
27: HANDLE hheap; /* The heap's handle */
28: PWSTR pwstr; /* Wide string to use */
29: {
30: /*
31: * Size the string, request heap space then copy string to it.
32: */
33:
34: int cStr;
35: PWSTR pwstrRet;
36:
37:
38: cStr = sizeof( WCHAR) * (wcslen( pwstr ) + 1); /* Plus null! */
39:
40: if( pwstrRet = (PWSTR)HeapAlloc( hheap, 0, cStr ) )
41: memcpy( pwstrRet, pwstr, cStr );
42:
43:
44: return pwstrRet;
45:
46: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.