This line :
Doesn't look quite right to me.
The use of malloc and free on a static pointer is not advisable as well. You should either malloc a new array in the body of the function and make the caller resposible for calling free on it, or require the caller to provide a buffer to use for the new wchar_t string.
Also I notice you are mixing delete and free. This is a very unsafe practice. You should pick one method (either malloc/free or new/delete) and stick with it.