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.11 by greg, Fri Mar 9 14:00:06 1990 UTC vs.
Revision 1.12 by greg, Fri May 3 15:22:24 1991 UTC

# 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 268 | 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 357 | 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