19 #include <grass/segment.h>
22 static int segment_select(SEGMENT *,
int);
47 if (n == SEG->scb[SEG->cur].n)
51 for (i = 0; i < SEG->nseg; i++)
52 if (n == SEG->scb[i].n)
53 return segment_select(SEG, i);
58 for (i = 0; i < SEG->nseg; i++)
59 if (SEG->scb[i].n < 0) {
63 else if (age < SEG->scb[i].age) {
65 age = SEG->scb[i].age;
69 if (SEG->scb[cur].n >= 0 && SEG->scb[cur].dirty)
75 SEG->scb[cur].dirty = 0;
78 read_result = read(SEG->fd, SEG->scb[cur].buf, SEG->size);
79 if (read_result != SEG->size) {
80 G_debug(2,
"segment_pagein: read_result=%d SEG->size=%d",
81 read_result, SEG->size);
85 else if (read_result == 0)
89 (
"segment_pagein: short count during read(), got %d, expected %d",
90 read_result, SEG->size);
95 return segment_select(SEG, cur);
99 static int segment_select(SEGMENT * SEG,
int n)
104 for (i = 0; i < SEG->nseg; i++)