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.9 by greg, Mon Jan 8 13:38:12 1990 UTC vs.
Revision 1.12 by greg, Fri May 3 15:22:24 1991 UTC

# Line 45 | Line 45 | char  *amblist[128];                   /* ambient include/exclude list
45   int  ambincl = -1;                      /* include == 1, exclude == 0 */
46  
47   int  greyscale = 0;                     /* map colors to brightness? */
48 < char  *devname = "X";                   /* output device name */
48 > char  *devname = dev_default;           /* output device name */
49  
50   struct driver  *dev = NULL;             /* driver functions */
51  
# Line 55 | Line 55 | PNODE  ptrunk;                         /* the base of our image */
55   RECT  pframe;                           /* current frame boundaries */
56   int  pdepth;                            /* image depth in current frame */
57  
58 + static char  *reserve_mem = NULL;       /* pre-allocated reserve memory */
59 +
60 + #define RESERVE_AMT     8192            /* amount of memory to reserve */
61 +
62   #define  CTRL(c)        ('c'-'@')
63  
64  
# Line 137 | Line 141 | rview()                                /* do a view */
141   }
142  
143  
144 + memreserve()                    /* fill memory reserves */
145 + {
146 +        if (reserve_mem != NULL)
147 +                return;                 /* got some already */
148 +        reserve_mem = malloc(RESERVE_AMT);
149 + }
150 +
151 +
152 + memerror(detail)                /* try and rescue a memory error */
153 + char    *detail;
154 + {
155 +        if (reserve_mem == NULL) {
156 +                sprintf(errmsg, "out of memory %s", detail);
157 +                error(SYSTEM, errmsg);
158 +        }
159 +        free(reserve_mem);
160 +        reserve_mem = NULL;
161 +        for ( ; ; )
162 +                command("out of memory: ");
163 + }
164 +
165 +
166   command(prompt)                 /* get/execute command */
167   char  *prompt;
168   {
# Line 145 | Line 171 | char  *prompt;
171          char  inpbuf[256];
172          char  *args;
173   again:
174 <        (*dev->comout)(prompt);                 /* get command + arguments */
149 <        (*dev->comin)(inpbuf);
174 >        (*dev->comin)(inpbuf, prompt);          /* get command + arguments */
175          for (args = inpbuf; *args && *args != ' '; args++)
176                  ;
177          if (*args) *args++ = '\0';
# Line 269 | Line 294 | rsample()                      /* sample the image */
294          xsiz = (((pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu;
295          ysiz = (((pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu;
296          rl = (RECT *)malloc(xsiz*sizeof(RECT));
297 +        if (rl == NULL)
298 +                memerror("in rsample");
299          pl = (PNODE **)malloc(xsiz*sizeof(PNODE *));
300 <        if (rl == NULL || pl == NULL)
301 <                error(SYSTEM, "out of memory in rsample");
300 >        if (pl == NULL)
301 >                memerror("in rsample");
302          /*
303           * Initialize the bottom row.
304           */
# Line 358 | Line 385 | int  pd;
385          if (p->kid == NULL) {                   /* subdivide */
386  
387                  if ((p->kid = newptree()) == NULL)
388 <                        error(SYSTEM, "out of memory in refine");
388 >                        memerror("in refine");
389                  /*
390                   *  The following paint order can leave a black pixel
391                   *  when redraw() is called in (*dev->paintr)().

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines