A
Adam Clauss
I have a doc/view app w/ a CRichEditView. In it, I define:
void CSyntaxView:arseLine(long lineNum);
This function starts off by getting the text of the specified line (into a
CString):
CRichEditCtrl* ctrl = &GetRichEditCtrl();
int lineLen = ctrl->LineLength(lineNum);
char* buf = new char[lineLen];
ctrl->GetLine(lineNum, buf, lineLen);
CString line = buf;
line = line.Left(lineLen);
delete[] buf; ** Problem
buf = NULL;
However, when running in debug, I get an error on the delete line:
DAMAGE: after Normal block (#222) at 0x00337EF0.
I have tried using both delete[] and just delete and I get the error either
way. What am I doing wrong here???
If it would help here, is there an easier way to get the specified line into
a CString?
void CSyntaxView:arseLine(long lineNum);
This function starts off by getting the text of the specified line (into a
CString):
CRichEditCtrl* ctrl = &GetRichEditCtrl();
int lineLen = ctrl->LineLength(lineNum);
char* buf = new char[lineLen];
ctrl->GetLine(lineNum, buf, lineLen);
CString line = buf;
line = line.Left(lineLen);
delete[] buf; ** Problem
buf = NULL;
However, when running in debug, I get an error on the delete line:
DAMAGE: after Normal block (#222) at 0x00337EF0.
I have tried using both delete[] and just delete and I get the error either
way. What am I doing wrong here???
If it would help here, is there an easier way to get the specified line into
a CString?