utilitylibraries/libutils/src/stringtodescriptor16.cpp
branchRCL_3
changeset 57 2efc27d87e1c
parent 56 acd3cd4aaceb
--- a/utilitylibraries/libutils/src/stringtodescriptor16.cpp	Tue Aug 31 16:54:36 2010 +0300
+++ b/utilitylibraries/libutils/src/stringtodescriptor16.cpp	Wed Sep 01 12:36:54 2010 +0100
@@ -28,7 +28,7 @@
    * reference to the descriptor where the result of conversion 
    * is stored,n_size specifies the conversion size of the char array 
    * @return Status code (0 is ESuccess, -1 is EInsufficientMemory, 
-   * -3 is EStringNoData, -9 is EInsufficientSystemMemory)
+   * -3 is EStringNoData)
    */
 EXPORT_C  int StringToTbuf16(string& aSrc, TDes16& aDes)
 {
@@ -164,8 +164,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, -6 is EUseNewMaxL,
-   * -9 is EInsufficientSystemMemory)
+   * -3 is EStringNoData)
    */
 
 EXPORT_C int StringToHbufc16(string& aSrc , HBufC16* aDes)
@@ -224,7 +223,7 @@
    * reference to the descriptor where the result of conversion 
    * is stored 
    * @return Status code (0 is ESuccess, -1 is EInsufficientMemory, 
-   * -3 is EStringNoData, -7 is EInvalidMBSSequence, -9 is EInsufficientSystemMemory)
+   * -3 is EStringNoData )
    */
 
 EXPORT_C int StringToRbuf16(const string& aSrc, RBuf16& aDes)
@@ -251,13 +250,23 @@
 
 	if(minusone != mbstowcs(buf, charString, ilen))
 	{
-	  aDes.Copy((const unsigned short *)buf, ilen);		
+	    int ret = aDes.Create(ilen);
+	    if (KErrNone == ret)
+	    {
+	    	aDes.Copy((const unsigned short *)buf, ilen);	
+	    }
+	    else 
+	    {
+	        retval = EInsufficientSystemMemory;	
+	    }
+		
 	}
 	else
 	{
-	  retval = EInvalidMBSSequence;		
+	    retval = EInvalidMBSSequence;
+		
 	}
 	
 	delete []buf;
-  return retval;	
+    return retval;	
 }