| 121 |
|
free(idmp); |
| 122 |
|
return NULL; |
| 123 |
|
} |
| 124 |
< |
if (fseek(idmp->finp, idmp->curpos = idmp->dstart, SEEK_SET) < 0) |
| 124 |
> |
if (fseek(idmp->finp, idmp->dstart, SEEK_SET) < 0) |
| 125 |
|
goto seekerr; |
| 126 |
|
while (tablength > 0) /* create index */ |
| 127 |
|
idmp->nids += !idmp->idtable[--tablength]; |
| 159 |
|
if (ndx == EOF && feof(idmp->finp)) |
| 160 |
|
return -1; |
| 161 |
|
|
| 162 |
– |
idmp->curpos += idmp->bytespi; |
| 163 |
– |
|
| 162 |
|
ndx &= (1<<(idmp->bytespi<<3)) - 1; /* undo sign extension */ |
| 163 |
|
|
| 164 |
|
return ndx; |
| 182 |
|
int |
| 183 |
|
idmap_seek(IDMAP *idmp, int x, int y) |
| 184 |
|
{ |
| 187 |
– |
long seekto; |
| 188 |
– |
|
| 185 |
|
if ((x < 0) | (y < 0) | (x >= idmp->res.xr) | (y >= idmp->res.yr)) |
| 186 |
|
return 0; |
| 187 |
|
|
| 188 |
< |
seekto = idmp->dstart + ((long)y*idmp->res.xr + x)*idmp->bytespi; |
| 189 |
< |
|
| 194 |
< |
if (seekto != idmp->curpos && fseek(idmp->finp, seekto, SEEK_SET) < 0) |
| 188 |
> |
if (fseek(idmp->finp, idmp->dstart + ((long)y*idmp->res.xr + x)*idmp->bytespi, |
| 189 |
> |
SEEK_SET) < 0) |
| 190 |
|
return -1; |
| 191 |
|
|
| 197 |
– |
idmp->curpos = seekto; |
| 198 |
– |
|
| 192 |
|
return 1; |
| 193 |
|
} |
| 194 |
|
|