utilitylibraries/libutils/src/wstringtodescriptor16.cpp
branchRCL_3
changeset 57 2efc27d87e1c
parent 56 acd3cd4aaceb
--- a/utilitylibraries/libutils/src/wstringtodescriptor16.cpp	Tue Aug 31 16:54:36 2010 +0300
+++ b/utilitylibraries/libutils/src/wstringtodescriptor16.cpp	Wed Sep 01 12:36:54 2010 +0100
@@ -59,7 +59,7 @@
    * @param aSrc is the wstring to be converted , aDes is the 
    * reference to the descriptor where the result of conversion 
    * is stored 
-   * @return Status code (0 is ESuccess, -3 is EStringNoData, -1 is EInsufficientMemory)
+   * @return Status code (0 is ESuccess, -3 is EStringNoData)
    */
 
 EXPORT_C int WstringToTptr16(wstring& aSrc, TPtr16& aDes )
@@ -114,7 +114,7 @@
    * reference to the descriptor where the result of conversion 
    * is stored 
    * @return Status code (0 is ESuccess, -1 is EInsufficientMemory, 
-   * -3 is EStringNoData, -4 is EInvalidPointer )
+   * -3 is EStringNoData )
    */
 
 EXPORT_C int WstringToHbufc16(wstring& aSrc, HBufC16* aDes)
@@ -168,8 +168,15 @@
     }
     
     wlen = wcslen(wcharString);
-
-    aDes.Copy((const unsigned short *)wcharString, wlen);	
-
-	  return retval;
+    
+    if (KErrNone == aDes.Create(wlen))
+    {
+        aDes.Copy((const unsigned short *)wcharString, wlen);	
+    }
+    else 
+    {
+    	retval = EInsufficientSystemMemory;
+    }
+	
+	return retval;
 }