Wide-character-string allocation

When you represent a wide-character string in an array, the number of array elements does equal the number of wide characters in the string. Therefore, you can use the same allocation method for wide-character strings as for single-byte strings.

For example, the following declaration statically allocates 20 wide characters for the wcs string:
gl_wchar_t wcs[20];
The following declaration dynamically allocates 20 wide characters for the wc1 string:
gl_wchar_t *wcs1 = (gl_wchar_t *) malloc(20*sizeof(gl_wchar_t));
If your wide-character string is null terminated, you must allocate one additional character for the null terminator. The null terminator requires the same space allocated as an entire wide-character. The following declaration allocates three null-terminated wide-character strings:
/* static allocation */
gl_wchar_t wcs[21];
/* dynamic allocation */
gl_wchar_t *wcs3 = (gl_wchar_t *) malloc(21*sizeof(gl_wchar_t));