Use BTextView::Copy/FreeRunArray() instead of memcpy() and free()
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19938 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2006, Haiku, Inc.
|
* Copyright 2003-2007, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -41,14 +41,14 @@ _BUndoBuffer_::_BUndoBuffer_(BTextView *textView, undo_state state)
|
|||||||
memcpy(fTextData, fTextView->Text() + fStart, fTextLength);
|
memcpy(fTextData, fTextView->Text() + fStart, fTextLength);
|
||||||
|
|
||||||
if (fTextView->IsStylable())
|
if (fTextView->IsStylable())
|
||||||
fRunArray = fTextView->RunArray(fStart, fEnd, &fRunArrayLength);
|
fRunArray = fTextView->RunArray(fStart, fEnd, &fRunArrayLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_BUndoBuffer_::~_BUndoBuffer_()
|
_BUndoBuffer_::~_BUndoBuffer_()
|
||||||
{
|
{
|
||||||
free(fTextData);
|
free(fTextData);
|
||||||
free(fRunArray);
|
BTextView::FreeRunArray(fRunArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -128,24 +128,20 @@ _BPasteUndoBuffer_::_BPasteUndoBuffer_(BTextView *textView, const char *text,
|
|||||||
: _BUndoBuffer_(textView, B_UNDO_PASTE),
|
: _BUndoBuffer_(textView, B_UNDO_PASTE),
|
||||||
fPasteText(NULL),
|
fPasteText(NULL),
|
||||||
fPasteTextLength(textLen),
|
fPasteTextLength(textLen),
|
||||||
fPasteRunArray(NULL),
|
fPasteRunArray(NULL)
|
||||||
fPasteRunArrayLength(0)
|
|
||||||
{
|
{
|
||||||
fPasteText = (char *)malloc(fPasteTextLength);
|
fPasteText = (char *)malloc(fPasteTextLength);
|
||||||
memcpy(fPasteText, text, fPasteTextLength);
|
memcpy(fPasteText, text, fPasteTextLength);
|
||||||
|
|
||||||
if (runArray) {
|
if (runArray)
|
||||||
fPasteRunArray = (text_run_array *)malloc(runArrayLen);
|
fPasteRunArray = BTextView::CopyRunArray(runArray);
|
||||||
fPasteRunArrayLength = runArrayLen;
|
|
||||||
memcpy(fPasteRunArray, runArray, runArrayLen);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_BPasteUndoBuffer_::~_BPasteUndoBuffer_()
|
_BPasteUndoBuffer_::~_BPasteUndoBuffer_()
|
||||||
{
|
{
|
||||||
free(fPasteText);
|
free(fPasteText);
|
||||||
free(fPasteRunArray);
|
BTextView::FreeRunArray(fPasteRunArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -208,11 +204,8 @@ _BDropUndoBuffer_::_BDropUndoBuffer_(BTextView *textView, char const *text,
|
|||||||
fDropText = (char *)malloc(fDropTextLength);
|
fDropText = (char *)malloc(fDropTextLength);
|
||||||
memcpy(fDropText, text, fDropTextLength);
|
memcpy(fDropText, text, fDropTextLength);
|
||||||
|
|
||||||
if (runArray) {
|
if (runArray)
|
||||||
fDropRunArray = (text_run_array *)malloc(runArrayLen);
|
fDropRunArray = BTextView::CopyRunArray(runArray);
|
||||||
fDropRunArrayLength = runArrayLen;
|
|
||||||
memcpy(fDropRunArray, runArray, runArrayLen);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fInternalDrop && fDropLocation >= fEnd)
|
if (fInternalDrop && fDropLocation >= fEnd)
|
||||||
fDropLocation -= fDropTextLength;
|
fDropLocation -= fDropTextLength;
|
||||||
@@ -222,7 +215,7 @@ _BDropUndoBuffer_::_BDropUndoBuffer_(BTextView *textView, char const *text,
|
|||||||
_BDropUndoBuffer_::~_BDropUndoBuffer_()
|
_BDropUndoBuffer_::~_BDropUndoBuffer_()
|
||||||
{
|
{
|
||||||
free(fDropText);
|
free(fDropText);
|
||||||
free(fDropRunArray);
|
BTextView::FreeRunArray(fDropRunArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2004, Haiku, Inc. All Rights Reserved.
|
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -67,7 +67,6 @@ private:
|
|||||||
char *fPasteText;
|
char *fPasteText;
|
||||||
int32 fPasteTextLength;
|
int32 fPasteTextLength;
|
||||||
text_run_array *fPasteRunArray;
|
text_run_array *fPasteRunArray;
|
||||||
int32 fPasteRunArrayLength;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -96,7 +95,6 @@ private:
|
|||||||
char *fDropText;
|
char *fDropText;
|
||||||
int32 fDropTextLength;
|
int32 fDropTextLength;
|
||||||
text_run_array *fDropRunArray;
|
text_run_array *fDropRunArray;
|
||||||
int32 fDropRunArrayLength;
|
|
||||||
|
|
||||||
int32 fDropLocation;
|
int32 fDropLocation;
|
||||||
bool fInternalDrop;
|
bool fInternalDrop;
|
||||||
|
|||||||
Reference in New Issue
Block a user