Mail Archives: djgpp/1999/12/23/11:19:27
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 !!!
- Raw text -