ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/rview.c
(Generate patch)

Comparing ray/src/rt/rview.c (file contents):
Revision 1.10 by greg, Tue Jan 30 11:37:41 1990 UTC vs.
Revision 1.13 by greg, Fri May 3 15:43:32 1991 UTC

# Line 18 | Line 18 | static char SCCSid[] = "$SunId$ LBL";
18  
19   #include  <signal.h>
20  
21 + #include  <setjmp.h>
22 +
23   #include  <ctype.h>
24  
25   VIEW  ourview = STDVIEW;                /* viewing parameters */
# Line 45 | Line 47 | char  *amblist[128];                   /* ambient include/exclude list
47   int  ambincl = -1;                      /* include == 1, exclude == 0 */
48  
49   int  greyscale = 0;                     /* map colors to brightness? */
50 < char  *devname = "X";                   /* output device name */
50 > char  *devname = dev_default;           /* output device name */
51  
52   struct driver  *dev = NULL;             /* driver functions */
53  
# Line 55 | Line 57 | PNODE  ptrunk;                         /* the base of our image */
57   RECT  pframe;                           /* current frame boundaries */
58   int  pdepth;                            /* image depth in current frame */
59  
60 + static jmp_buf  mainloop;               /* longjmp back to main loop */
61 + static char  *reserve_mem = NULL;       /* pre-allocated reserve memory */
62 +
63 + #define RESERVE_AMT     8192            /* amount of memory to reserve */
64 +
65   #define  CTRL(c)        ('c'-'@')
66  
67  
# Line 113 | Line 120 | rview()                                /* do a view */
120  
121          devopen(devname);               /* open device */
122          newimage();                     /* set up image */
123 <
123 >        setjmp(mainloop);
124          for ( ; ; ) {                   /* quit in command() */
125                  while (hresolu <= 1<<pdepth &&
126                                  vresolu <= 1<<pdepth)
# Line 137 | Line 144 | rview()                                /* do a view */
144   }
145  
146  
147 + memreserve()                    /* fill memory reserves */
148 + {
149 +        if (reserve_mem != NULL)
150 +                return;                 /* got some already */
151 +        reserve_mem = malloc(RESERVE_AMT);
152 + }
153 +
154 +
155 + memerror(detail)                /* try and rescue a memory error */
156 + char    *detail;
157 + {
158 +        if (reserve_mem == NULL) {
159 +                sprintf(errmsg, "out of memory %s", detail);
160 +                error(SYSTEM, errmsg);
161 +        }
162 +        free(reserve_mem);
163 +        reserve_mem = NULL;
164 +        do
165 +                command("out of memory: ");
166 +        while (reserve_mem == NULL);
167 +        longjmp(mainloop, 1);
168 + }
169 +
170 +
171   command(prompt)                 /* get/execute command */
172   char  *prompt;
173   {
# Line 268 | Line 299 | rsample()                      /* sample the image */
299          xsiz = (((pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu;
300          ysiz = (((pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu;
301          rl = (RECT *)malloc(xsiz*sizeof(RECT));
302 +        if (rl == NULL)
303 +                memerror("in rsample");
304          pl = (PNODE **)malloc(xsiz*sizeof(PNODE *));
305 <        if (rl == NULL || pl == NULL)
306 <                error(SYSTEM, "out of memory in rsample");
305 >        if (pl == NULL)
306 >                memerror("in rsample");
307          /*
308           * Initialize the bottom row.
309           */
# Line 357 | Line 390 | int  pd;
390          if (p->kid == NULL) {                   /* subdivide */
391  
392                  if ((p->kid = newptree()) == NULL)
393 <                        error(SYSTEM, "out of memory in refine");
393 >                        memerror("in refine");
394                  /*
395                   *  The following paint order can leave a black pixel
396                   *  when redraw() is called in (*dev->paintr)().

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines