From: qballlives AT aol DOT com (QBallLives) Newsgroups: comp.os.msdos.djgpp Subject: Re: Double Buffer Date: 22 Mar 1998 07:17:18 GMT Lines: 39 Message-ID: <1998032207171801.CAA14377@ladder01.news.aol.com> NNTP-Posting-Host: ladder01.news.aol.com Organization: AOL http://www.aol.com References: <1998032123310801 DOT SAA04527 AT ladder03 DOT news DOT aol DOT com> To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk > >I have this function to create a double buffer, but it always returns 0, yet >I >can still write to and copy the double buffer to the screen. > >unsigned char *double_buffer = NULL; >unsigned int buffer_height = 200; >unsigned int buffer_size = 320 * 200; > >int Create_Double_Buffer(int num_lines) >{ >if ((double_buffer = (unsigned char *)malloc(320 * (num_lines + 1))) == NULL) > return(0); > >/* Set the height of the buffer and compute its size */ > >buffer_height = num_lines; >buffer_size = 200 * num_lines/2; > >/* Fill the buffer with black (clear) */ > >memset(double_buffer, 0, 200 * num_lines); > >/* Everything was ok */ > >return (1); > >} hmmm... try : if (!(double_buffer = malloc(320 * num_lines + 1)) ) Jim the loiterer aloiterer AT juno DOT com http://www.fortunecity.com/skyscraper/gigahertz/179/index.html