Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!ucbvax!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!strath-cs!sglen From: sglen@cs.strath.ac.uk (Scott M Glen CS89) Newsgroups: comp.lang.c Subject: Turbo - C Message-ID: <6204@baird.cs.strath.ac.uk> Date: 21 Mar 91 11:16:34 GMT Organization: Comp. Sci. Dept., Strathclyde Univ., Scotland. Lines: 57 Can anyone tell my why the following Turbo-c code causes a crash. (I am using Turbo-c V2, on an NTS PC). Basically it's a trivial piece of code, to save a small rectangular area of the screen to memory, write something in the area (in this case a black rectangle) and then restore the screen to its original status. void help_option1 (void) { int i; void *buffer; unsigned size; size=imagesize(0,0,20,20); /* define rectangle to be saved */ if (size!=-1) /* if area is too large imagesize returns -1 */ { buffer=malloc (size); /* allocate memory for area of screen */ getimage (0,0,20,20); setfillstyle (SOLID_FILL,BLACK); bar (0,0,20,20); /* black out the rectangle */ i=getch(); /* wait for a key */ putimage (0,0,buffer,COPY_PUT); /* restore rectangle free (buffer); } else { /* image too large */ } } When it runs, the black box apewars as expected, but then the screen freezes I don't even know whether the problem lies with saving the area, or restoring it. Any help would be very much appreciated..... ****************************************************************************** * * * Scott Glen * * 3rd Year Computer Science * * The University Of Strathclyde * * Glasgow * * Scotland * * * * cadx830@uk.ac.strathclyde.computer-centre-sun * * sglen@uk.ac.strathclyde.cs * * * ******************************************************************************