* It gives sliding window access to a file. mmap() is not used because of
* the possibility of another program (such as a mailer) truncating the
* file thus giving us a SIGBUS. */
-struct map_struct *map_file(int fd, OFF_T len, int32 read_size,
- int32 blk_size)
+struct map_struct *map_file(int fd, OFF_T len, int32 read_size, int32 blk_size)
{
struct map_struct *map;
/* slide the read window in the file */
char *map_ptr(struct map_struct *map, OFF_T offset, int32 len)
{
- int32 nread;
OFF_T window_start, read_start;
int32 window_size, read_size, read_offset;
map->p_size = window_size;
}
- /* Now try to avoid re-reading any bytes by reusing any bytes
- * from the previous buffer. */
- if (window_start >= map->p_offset &&
- window_start < map->p_offset + map->p_len &&
- window_start + window_size >= map->p_offset + map->p_len) {
+ /* Now try to avoid re-reading any bytes by reusing any bytes from the previous buffer. */
+ if (window_start >= map->p_offset && window_start < map->p_offset + map->p_len
+ && window_start + window_size >= map->p_offset + map->p_len) {
read_start = map->p_offset + map->p_len;
read_offset = (int32)(read_start - window_start);
read_size = window_size - read_offset;
map->p_len = window_size;
while (read_size > 0) {
- nread = read(map->fd, map->p + read_offset, read_size);
+ int32 nread = read(map->fd, map->p + read_offset, read_size);
if (nread <= 0) {
if (!map->status)
map->status = nread ? errno : ENODATA;