View Issue Details

IDProjectCategoryView StatusLast Update
0001383Far ManagerEditorpublic2010-05-15 14:42
Reporteralexfh Assigned Toalexy  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version2.0 
Fixed in Version2.0 
Summary0001383: Дополнения для #1224
DescriptionВдогонку к #1224 патч для VBlock2Text.
TagsNo tags attached.
Build1555

Activities

alexfh

2010-05-15 12:57

reporter  

editor.cpp.patch (1,712 bytes)   
Index: editor.cpp
===================================================================
--- editor.cpp	(revision 4680)
+++ editor.cpp	(working copy)
@@ -4970,22 +4970,40 @@
 
 wchar_t *Editor::VBlock2Text(wchar_t *ptrInitData)
 {
-	wchar_t *CopyData=nullptr;
 	size_t DataSize=0;
 
 	if (ptrInitData)
+		DataSize = wcslen(ptrInitData);
+
+	size_t TotalChars = DataSize;
+
+	Edit *CurPtr=VBlockStart;
+
+	for (int Line=0; CurPtr!=nullptr && Line<VBlockSizeY; Line++,CurPtr=CurPtr->m_next)
 	{
-		if ((CopyData = xf_wcsdup(ptrInitData)) == nullptr)
-		{
+		TotalChars += CurPtr->TabPosToReal(VBlockX+VBlockSizeX) - CurPtr->TabPosToReal(VBlockX);
+		TotalChars += 2; // CRLF
+	}
+
+	++TotalChars; // '\0'
+
+	wchar_t *CopyData=(wchar_t *)xf_malloc(TotalChars*sizeof(wchar_t));
+
+	if (!CopyData)
+	{
+		if (ptrInitData)
 			xf_free(ptrInitData);
-			return nullptr;
-		}
 
+		return nullptr;
+	}
+
+	if (ptrInitData)
+	{
+		wcscpy(CopyData,ptrInitData);
 		xf_free(ptrInitData);
-		DataSize = StrLength(CopyData);
 	}
 
-	Edit *CurPtr=VBlockStart;
+	CurPtr=VBlockStart;
 
 	for (int Line=0; CurPtr!=nullptr && Line<VBlockSizeY; Line++,CurPtr=CurPtr->m_next)
 	{
@@ -4994,22 +5012,7 @@
 		const wchar_t *CurStr,*EndSeq;
 		int Length;
 		CurPtr->GetBinaryString(&CurStr,&EndSeq,Length);
-		size_t AllocSize=Max(DataSize+Length+3,DataSize+TBlockSizeX+3);
-		wchar_t *NewPtr=(wchar_t *)xf_realloc(CopyData,AllocSize*sizeof(wchar_t));
 
-		if (NewPtr==nullptr)
-		{
-			if (CopyData)
-			{
-				xf_free(CopyData);
-				CopyData=nullptr;
-			}
-
-			break;
-		}
-
-		CopyData=NewPtr;
-
 		if (Length>TBlockX)
 		{
 			int CopySize=Length-TBlockX;
editor.cpp.patch (1,712 bytes)   

alexy

2010-05-15 14:12

administrator   bugnote:0005374

1555

alexfh

2010-05-15 14:25

reporter   bugnote:0005375

ну да, все путем

Issue History

Date Modified Username Field Change
2010-05-15 12:57 alexfh New Issue
2010-05-15 12:57 alexfh File Added: editor.cpp.patch
2010-05-15 14:12 alexy Note Added: 0005374
2010-05-15 14:12 alexy Assigned To => alexy
2010-05-15 14:12 alexy Status new => feedback
2010-05-15 14:25 alexfh Note Added: 0005375
2010-05-15 14:25 alexfh Status feedback => assigned
2010-05-15 14:42 alexy Build => 1555
2010-05-15 14:42 alexy Status assigned => closed
2010-05-15 14:42 alexy Resolution open => fixed
2010-05-15 14:42 alexy Fixed in Version => 2.0