mothra: limit amount of image data kept in devdraw to 8MB
This commit is contained in:
parent
92fa7cbcd1
commit
322f72313d
3 changed files with 32 additions and 17 deletions
|
@ -21,12 +21,6 @@ char *pixcmd[]={
|
|||
[BMP] "bmp -9t",
|
||||
};
|
||||
|
||||
void storebitmap(Rtext *t, Image *b){
|
||||
t->b=b;
|
||||
free(t->text);
|
||||
t->text=0;
|
||||
}
|
||||
|
||||
void getimage(Rtext *t, Www *w){
|
||||
int pfd[2];
|
||||
Action *ap;
|
||||
|
@ -40,7 +34,7 @@ void getimage(Rtext *t, Www *w){
|
|||
seturl(&url, ap->image, w->url->fullname);
|
||||
for(p=w->pix;p!=nil; p=p->next)
|
||||
if(strcmp(ap->image, p->name)==0 && ap->width==p->width && ap->height==p->height){
|
||||
storebitmap(t, p->b);
|
||||
t->b = p->b;
|
||||
w->changed=1;
|
||||
return;
|
||||
}
|
||||
|
@ -87,7 +81,7 @@ void getimage(Rtext *t, Www *w){
|
|||
p->height=ap->height;
|
||||
p->next=w->pix;
|
||||
w->pix=p;
|
||||
storebitmap(t, b);
|
||||
t->b=b;
|
||||
w->changed=1;
|
||||
}
|
||||
|
||||
|
@ -144,8 +138,15 @@ void getpix(Rtext *t, Www *w){
|
|||
}
|
||||
}
|
||||
|
||||
void freepix(void *p)
|
||||
{
|
||||
ulong countpix(void *p){
|
||||
ulong n=0;
|
||||
Pix *x;
|
||||
for(x = p; x; x = x->next)
|
||||
n += Dy(x->b->r)*bytesperline(x->b->r, x->b->depth);
|
||||
return n;
|
||||
}
|
||||
|
||||
void freepix(void *p){
|
||||
Pix *x, *xx;
|
||||
xx = p;
|
||||
while(x = xx){
|
||||
|
|
|
@ -961,9 +961,10 @@ void freeurl(Url *u){
|
|||
* get the file at the given url
|
||||
*/
|
||||
void geturl(char *urlname, int method, char *body, int plumb, int map){
|
||||
int i, fd, typ;
|
||||
int i, fd, typ, pfd[2];
|
||||
char cmd[NNAME];
|
||||
int pfd[2];
|
||||
Rtext *t;
|
||||
ulong n;
|
||||
Www *w;
|
||||
|
||||
if(*urlname == '#'){
|
||||
|
@ -1013,18 +1014,28 @@ void geturl(char *urlname, int method, char *body, int plumb, int map){
|
|||
case HTML:
|
||||
fd = pipeline("/bin/uhtml", fd);
|
||||
case PLAIN:
|
||||
n=0;
|
||||
for(i=wwwtop-1; i>=0 && i!=(wwwtop-NWWW-1); i--){
|
||||
w = www(i);
|
||||
n += countpix(w->pix);
|
||||
if(n < NPIXMB*1024*1024)
|
||||
continue;
|
||||
if(!w->finished && !w->alldone)
|
||||
continue;
|
||||
for(t=w->text; t; t=t->next)
|
||||
if(t->b && t->user)
|
||||
t->b=0;
|
||||
freepix(w->pix);
|
||||
w->pix=0;
|
||||
}
|
||||
w = www(i = wwwtop++);
|
||||
if(i >= NWWW){
|
||||
extern void freeform(void *p);
|
||||
extern void freepix(void *p);
|
||||
|
||||
/* wait for the reader to finish the document */
|
||||
while(!w->finished && !w->alldone){
|
||||
unlockdisplay(display);
|
||||
sleep(10);
|
||||
lockdisplay(display);
|
||||
}
|
||||
|
||||
freetext(w->text);
|
||||
freeform(w->form);
|
||||
freepix(w->pix);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
enum{
|
||||
NWWW=64, /* # of pages we hold in the log */
|
||||
NXPROC=5, /* # of parallel procs loading the pix */
|
||||
NPIXMB=8, /* megabytes of image data to keep arround */
|
||||
NNAME=512,
|
||||
NLINE=256,
|
||||
NAUTH=128,
|
||||
|
@ -82,12 +83,14 @@ void plrdplain(char *, int, Www *);
|
|||
void htmlerror(char *, int, char *, ...); /* user-supplied routine */
|
||||
void seturl(Url *, char *, char *);
|
||||
void getpix(Rtext *, Www *);
|
||||
ulong countpix(void *p);
|
||||
void freepix(void *p);
|
||||
int pipeline(char *, int);
|
||||
int urlopen(Url *, int, char *);
|
||||
void getfonts(void);
|
||||
void *emalloc(int);
|
||||
void *emallocz(int, int);
|
||||
void setbitmap(Rtext *);
|
||||
void freeform(void *p);
|
||||
void message(char *, ...);
|
||||
int snooptype(int fd);
|
||||
void mkfieldpanel(Rtext *);
|
||||
|
|
Loading…
Reference in a new issue