malloc() --> new[]

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3256 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 1999-08-03 23:59:38 +00:00
parent a547ebffd6
commit 2776d7c3bd
6 changed files with 30 additions and 30 deletions

View File

@ -140,11 +140,11 @@ wxString wxHtmlFilterHTML::ReadFile(const wxFSFile& file) const
wxString doc;
if (s == NULL) return wxEmptyString;
src = (char*) malloc(s -> GetSize() + 1);
src = new char[s -> GetSize() + 1];
src[s -> GetSize()] = 0;
s -> Read(src, s -> GetSize());
doc = src;
free(src);
delete[] src;
return doc;
}

View File

@ -154,15 +154,15 @@ wxHtmlHelpController::~wxHtmlHelpController()
delete m_ContentsImageList;
if (m_Contents) {
for (i = 0; i < m_ContentsCnt; i++) {
free(m_Contents[i].m_Page);
free(m_Contents[i].m_Name);
delete[] m_Contents[i].m_Page;
delete[] m_Contents[i].m_Name;
}
free(m_Contents);
}
if (m_Index) {
for (i = 0; i < m_IndexCnt; i++) {
free(m_Index[i].m_Page);
free(m_Index[i].m_Name);
delete[] m_Index[i].m_Page;
delete[] m_Index[i].m_Name;
}
free(m_Index);
}
@ -243,7 +243,7 @@ bool wxHtmlHelpController::AddBook(const wxString& book, bool show_wait_msg)
fsys.ChangePathTo(bookFull);
s = fi -> GetStream();
sz = s -> GetSize();
buff = (char*) malloc(sz+1);
buff = new char[sz+1];
buff[sz] = 0;
s -> Read(buff, sz);
lineptr = buff;
@ -259,7 +259,7 @@ bool wxHtmlHelpController::AddBook(const wxString& book, bool show_wait_msg)
if (strstr(linebuf, "Contents file=") == linebuf)
contents = linebuf + strlen("Contents file=");
}
free(buff);
delete[] buff;
bookr = new HtmlBookRecord(fsys.GetPath(), title, start);
@ -267,9 +267,9 @@ bool wxHtmlHelpController::AddBook(const wxString& book, bool show_wait_msg)
m_Contents = (HtmlContentsItem*) realloc(m_Contents, (m_ContentsCnt + HTML_REALLOC_STEP) * sizeof(HtmlContentsItem));
m_Contents[m_ContentsCnt].m_Level = 0;
m_Contents[m_ContentsCnt].m_ID = 0;
m_Contents[m_ContentsCnt].m_Page = (char*) malloc(start.Length() + 1);
m_Contents[m_ContentsCnt].m_Page = new char[start.Length() + 1];
strcpy(m_Contents[m_ContentsCnt].m_Page, start.c_str());
m_Contents[m_ContentsCnt].m_Name = (char*) malloc(title.Length() + 1);
m_Contents[m_ContentsCnt].m_Name = new char [title.Length() + 1];
strcpy(m_Contents[m_ContentsCnt].m_Name, title.c_str());
m_Contents[m_ContentsCnt].m_Book = bookr;
m_ContentsCnt++;
@ -527,7 +527,7 @@ void wxHtmlHelpController::CreateHelpWindow()
if (m_Frame) {
m_Frame -> Raise();
m_Frame -> Show(TRUE);
m_Frame -> Show(TRUE);
return;
}

View File

@ -78,9 +78,9 @@ bool HP_TagHandler::HandleTag(const wxHtmlTag& tag)
m_Items = (HtmlContentsItem*) realloc(m_Items, (m_ItemsCnt + HTML_REALLOC_STEP) * sizeof(HtmlContentsItem));
m_Items[m_ItemsCnt].m_Level = m_Level;
m_Items[m_ItemsCnt].m_ID = m_ID;
m_Items[m_ItemsCnt].m_Page = (char*) malloc(m_Page.Length() + 1);
m_Items[m_ItemsCnt].m_Page = new char[m_Page.Length() + 1];
strcpy(m_Items[m_ItemsCnt].m_Page, m_Page.c_str());
m_Items[m_ItemsCnt].m_Name = (char*) malloc(m_Name.Length() + 1);
m_Items[m_ItemsCnt].m_Name = new char [m_Name.Length() + 1];
strcpy(m_Items[m_ItemsCnt].m_Name, m_Name.c_str());
m_Items[m_ItemsCnt].m_Book = m_Book;
m_ItemsCnt++;
@ -130,27 +130,27 @@ void wxHtmlHelpController::LoadMSProject(HtmlBookRecord *book, wxFileSystem& fsy
f = fsys.OpenFile(contentsfile);
if (f) {
sz = f -> GetStream() -> GetSize();
buf = (char*) malloc(sz+1);
buf = new char[sz+1];
buf[sz] = 0;
f -> GetStream() -> Read(buf, sz);
delete f;
handler -> ReadIn(m_Contents, m_ContentsCnt);
parser.Parse(buf);
handler -> WriteOut(m_Contents, m_ContentsCnt);
free(buf);
delete[] buf;
}
f = fsys.OpenFile(indexfile);
if (f) {
sz = f -> GetStream() -> GetSize();
buf = (char*) malloc(sz+1);
buf = new char[sz+1];
buf[sz] = 0;
f -> GetStream() -> Read(buf, sz);
delete f;
handler -> ReadIn(m_Index, m_IndexCnt);
parser.Parse(buf);
handler -> WriteOut(m_Index, m_IndexCnt);
free(buf);
delete[] buf;
}
if (show_wait_msg) delete busyinfo;
}
@ -177,10 +177,10 @@ void wxHtmlHelpController::LoadCachedBook(HtmlBookRecord *book, wxInputStream *f
f -> Read(&x, sizeof(x));
m_Contents[i].m_ID = x;
f -> Read(&x, sizeof(x));
m_Contents[i].m_Name = (char*) malloc(x);
m_Contents[i].m_Name = new char[x];
f -> Read(m_Contents[i].m_Name, x);
f -> Read(&x, sizeof(x));
m_Contents[i].m_Page = (char*) malloc(x);
m_Contents[i].m_Page = new char[x];
f -> Read(m_Contents[i].m_Page, x);
m_Contents[i].m_Book = book;
}
@ -193,10 +193,10 @@ void wxHtmlHelpController::LoadCachedBook(HtmlBookRecord *book, wxInputStream *f
m_Index = (HtmlContentsItem*) realloc(m_Index, (m_IndexCnt / HTML_REALLOC_STEP + 1) * HTML_REALLOC_STEP * sizeof(HtmlContentsItem));
for (i = st; i < m_IndexCnt; i++) {
f -> Read(&x, sizeof(x));
m_Index[i].m_Name = (char*) malloc(x);
m_Index[i].m_Name = new char[x];
f -> Read(m_Index[i].m_Name, x);
f -> Read(&x, sizeof(x));
m_Index[i].m_Page = (char*) malloc(x);
m_Index[i].m_Page = new char[x];
f -> Read(m_Index[i].m_Page, x);
m_Index[i].m_Book = book;
}

View File

@ -64,7 +64,7 @@ wxHtmlTagsCache::wxHtmlTagsCache(const wxString& source)
i++;
}
dummy[i] = 0;
m_Cache[tg].Name = (char*) malloc(i+1);
m_Cache[tg].Name = new char[i+1];
memcpy(m_Cache[tg].Name, dummy, i+1);
while (src[pos] != '>') pos++;
@ -89,7 +89,7 @@ wxHtmlTagsCache::wxHtmlTagsCache(const wxString& source)
// ok, we're done, now we'll free .Name members of cache - we don't need it anymore:
for (i = 0; i < m_CacheSize; i++) {
free(m_Cache[i].Name);
delete[] m_Cache[i].Name;
m_Cache[i].Name = NULL;
}
}

View File

@ -169,7 +169,7 @@ void wxHtmlTableCell::ReallocRows(int rows)
m_CellInfo = (cellStruct**) realloc(m_CellInfo, sizeof(cellStruct*) * rows);
if (m_NumCols != 0) {
int x = rows - 1;
m_CellInfo[x] = (cellStruct*) malloc(sizeof(cellStruct) * m_NumCols);
m_CellInfo[x] = new cellStruct[m_NumCols];
for (int i = 0; i < m_NumCols; i++)
m_CellInfo[x][i].flag = cellFree;
}
@ -338,7 +338,7 @@ void wxHtmlTableCell::Layout(int w)
/* 3. sub-layout all cells: */
{
int *ypos = (int*) malloc(sizeof(int) * (m_NumRows + 1));
int *ypos = new int[m_NumRows + 1];
int actcol, actrow;
int fullwid;
@ -385,7 +385,7 @@ void wxHtmlTableCell::Layout(int w)
}
m_Height = ypos[m_NumRows];
free(ypos);
delete[] ypos;
}
}

View File

@ -35,8 +35,8 @@
void wxSearchEngine::LookFor(const wxString& keyword)
{
if (m_Keyword) free(m_Keyword);
m_Keyword = (char*) malloc(keyword.Length() + 1);
if (m_Keyword) delete[] m_Keyword;
m_Keyword = new char[keyword.Length() + 1];
strcpy(m_Keyword, keyword.c_str());
for (int i = strlen(m_Keyword) - 1; i >= 0; i--)
if ((m_Keyword[i] >= 'A') && (m_Keyword[i] <= 'Z'))
@ -53,7 +53,7 @@ bool wxSearchEngine::Scan(wxInputStream *stream)
int lng = stream ->GetSize();
int wrd = strlen(m_Keyword);
bool found = FALSE;
char *buf = (char*) malloc(lng + 1);
char *buf = new char[lng + 1];
stream -> Read(buf, lng);
buf[lng] = 0;
@ -66,7 +66,7 @@ bool wxSearchEngine::Scan(wxInputStream *stream)
if (j == wrd) {found = TRUE; break;}
}
free(buf);
delete[] buf;
return found;
}