6 int search_cache(EPP *epp,int row);
7 void position_input(EPP *epp,int row);
8 void position_cached(EPP *epp, int row)/* makes given line current */
10 if (row==epp->currentline) return;
11 if (!search_cache(epp,row))
12 { position_input(epp,row);
15 typedef struct CACHE_REC { int row_no;
16 unsigned short *row_ptr;} cache_rec;
17 int search_cache(EPP *epp,int row)
18 { cache_rec* c;unsigned short int *rp;
20 for(c=epp->cache,i=0;i<epp->cache_size && c->row_no!=BAD_ROW&&c->row_no!=row;
22 if (i==epp->cache_size) {
23 /* Cache is full and row not found. Discard last row */
28 epp->currentline=c->row_no;
29 /* move all rows one forward */
30 for(;c!=epp->cache;c--) *c=*(c-1);
31 c=epp->cache;/* may be this is not nessecary*/
35 return epp->currentline==row;
37 void free_cache(EPP *epp)
39 for (i=0,c=epp->cache;i<epp->cache_size;i++,c++)
41 if (epp->cache) free(epp->cache);
45 int set_epp_cache(EPP *epp,int lines)
46 { int i; cache_rec* c;
47 if (!(epp->mode&MAP_INPUT)||(epp->mode&MAP_LOADED))
48 { map_error = ME_INVALID_MODE;
52 /* this is really assignment inside condition*/
54 {if (!(epp->cache=calloc(lines, sizeof(cache_rec))))
56 for (i=0,c=epp->cache;i<lines;i++,c++)
57 { c->row_ptr=calloc(epp->width+1,sizeof(short));
60 epp->cache_size=lines;
61 epp->position=position_cached;
63 else epp->position=position_input;