From: alainm AT news DOT RISQ DOT QC DOT CA (Alain Magloire) Subject: Re: djgpp strangeness Newsgroups: comp.os.msdos.djgpp References: <14684.897$Qz2 DOT 16629 AT wagner DOT videotron DOT net> X-Newsreader: TIN [version 1.2 PL2] Lines: 65 Message-ID: Date: Thu, 23 Dec 1999 01:00:40 GMT NNTP-Posting-Host: 132.206.63.174 X-Complaints-To: abuse AT mcgill DOT ca X-Trace: carnaval.risq.qc.ca 945910840 132.206.63.174 (Wed, 22 Dec 1999 20:00:40 EST) NNTP-Posting-Date: Wed, 22 Dec 1999 20:00:40 EST To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com If you are writting in C++, then do. If you want to use C, then use C. malloc/free are not the preferred way to allocate objects and manage memory, in C++. I do not remember what the std say, but malloc() will give uninitialized memory, and free () is not even require to invoke the destructor, when the object is collected. Use new and delete. -- alain Valkir (jfd50 AT videotron DOT ca) wrote: : Here's the code: : int main() : {long x,y; : uchar *Video; : Buffer=(uchar *)malloc(1920000); : cVesa *Vesa=(cVesa *)malloc(sizeof(cVesa)); : Video=Vesa->InitVesa(); : //////// cDesktop *Deskt=(cDesktop *)malloc(sizeof(cDesktop)); : for(x=0;x<800;x++) : for(y=0;y<2400;y++) : *(Buffer+y*800+x)=x; : memcpy(Video,Buffer,1920000); : getkey(); : Vesa->Close(); : return(0); : } : if I remove the command with lots of comments, it work, but if I enable it, : it doesn't enable my vesa mode but a 13h mode even if I don't use it : anywhere! : here's my constructor of cDesktop : cDesktop::cDesktop(){ : Menu.ChangeForm(0,0,799,19); : Icone.ChangeForm(0,20,799,39); : Opt.ChangeForm(0,40,99,599); : Image.ChangeForm(100,40,699,599); : Obj.ChangeForm(700,40,799,599); : } : void cItem::ChangeForm(uint xD,uint yD, uint xF, uint yF){ : xDebut=xD; /// Variable in my public class : yDebut=yD; : xFin=xF; : yFin=yF; : } : My constructor of cItem as nothing in it. : This is only 1 example, but it happend often. : thanks for help, Val -- au revoir, alain ---- Aussi haut que l'on soit assis, on est toujours assis que sur son cul !!!