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 |
|
|
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 |
|
|
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 |
|
{ |
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 |
|
*/ |
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)(). |