Mail Archives: djgpp/1996/09/18/17:13:47
From: | cs3prj04 AT lion DOT cs DOT latrobe DOT edu DOT au (Cs3prj Group 04)
|
Newsgroups: | comp.lang.c,comp.lang.c++,comp.os.msdos.djgpp
|
Subject: | Bus error with g++ (in t_delete in call to malloc)
|
Date: | 18 Sep 1996 14:30:46 GMT
|
Organization: | Comp.Sci & Comp.Eng, La Trobe Uni, Australia
|
Lines: | 68
|
Distribution: | world
|
Message-ID: | <51p12m$i9q@lion.cs.latrobe.edu.au>
|
NNTP-Posting-Host: | lion.cs.latrobe.edu.au
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Can anyone suggest why the below file reading code causes a bus error in all
subsequent calls to malloc or new i.e. bus error in t_delete in call to
malloc......
Also how the frick do you get seekg(...) to work. It would be nice if I
could do the equivalent of pascal reset(var file:text) rather than closing
the file and re-opening it. Unfortunately I can simply not get seekg to move
the file pointer back to the start of the file and I have tried many
different ways e.g. seekg(0) and seekg(InFile.beg,0).
// The constructors.
ViewDialogBoxC::ViewDialogBoxC(const int X1,const int Y1,const int X2,
const int Y2,const char *Caption_,
WINDOW *Win_,const char *FileName):
DialogBoxC(X1,Y1,X2,Y2,Caption_,Win_),Instructions(),String()
{
StringC Line;
int Index;
ifstream InFile(FileName);
if ((!InFile) && (FileName!=""))
{
cout<<"ERROR : unable to open file '"<<FileName<<"'...\n\n";
exit(1);
}
else if ((!InFile) && (FileName==""))
{
cout<<"ERROR : null file name...\n\n";
exit(1);
}
else
{
NumberLines=0;
do
{
InFile>>Line;
if (!InFile.eof())
NumberLines++;
}
while (!InFile.eof());
InFile.close();
InFile.open(FileName);
NumberLines=100;
Lines=new StringC[NumberLines];
for (Index=0;Index<NumberLines;Index++)
InFile>>Lines[Index];
InFile.close();
FirstLine=1;
if (NumberLines>Height)
LastLine=Height;
else
LastLine=NumberLines;
StringPos=1;
Instructions="Quit:Esc Type a string:alphanumeric search";
}
}
- Raw text -