23#include "local_proto.h"
46 if (
SEG->nrows <= 0 ||
SEG->ncols <= 0 ||
SEG->srows <= 0 ||
47 SEG->scols <= 0 ||
SEG->len <= 0 ||
SEG->nseg <= 0) {
48 G_warning(
"Segment setup: illegal segment file parameters");
55 if (
SEG->offset == -1) {
81 SEG->segbits =
SEG->srowbits +
SEG->scolbits;
83 G_debug(1,
"Segment setup: fast address activated");
93 if (
SEG->fast_adrs == 1) {
99 SEG->sizebits =
SEG->segbits +
SEG->lenbits;
101 G_debug(1,
"Segment setup: fast seek activated");
113 "Segment setup: reducing number of open segments from %d to %d",
118 if ((
SEG->scb = (
struct scb *)
G_malloc(
SEG->nseg *
sizeof(
struct scb))) ==
126 sizeof(
struct aq))) ==
NULL)
129 SEG->srowscols =
SEG->srows *
SEG->scols;
132 for (i = 0; i <
SEG->nseg; i++) {
137 SEG->scb[i].dirty = 0;
139 SEG->freeslot[i] = i;
140 SEG->agequeue[i].cur = -1;
142 SEG->agequeue[i].younger = &(
SEG->agequeue[i - 1]);
143 SEG->agequeue[i].older = &(
SEG->agequeue[i + 1]);
146 SEG->agequeue[i].younger = &(
SEG->agequeue[
SEG->nseg]);
147 SEG->agequeue[i].older = &(
SEG->agequeue[i + 1]);
151 SEG->agequeue[
SEG->nseg].cur = -1;
152 SEG->agequeue[
SEG->nseg].younger = &(
SEG->agequeue[
SEG->nseg - 1]);
153 SEG->agequeue[
SEG->nseg].older = &(
SEG->agequeue[0]);
154 SEG->youngest =
SEG->oldest = &(
SEG->agequeue[
SEG->nseg]);
156 SEG->nfreeslots =
SEG->nseg;
169 SEG->load_idx[i] = -1;
int seg_address_slow(const SEGMENT *SEG, off_t row, off_t col, int *n, int *index)
int seg_address_fast(const SEGMENT *SEG, off_t row, off_t col, int *n, int *index)
AMI_err seek(off_t offset)
void G_warning(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
int seg_seek_fast(const SEGMENT *SEG, int n, int index)
int seg_seek_slow(const SEGMENT *SEG, int n, int index)
int seg_setup(SEGMENT *SEG)
Internal use only.
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)