Lines Matching defs:index
9 its entirety, and an index built with access points about every SPAN bytes
24 To use the index, an offset in the uncompressed data is provided, for which
25 the latest accees point at or preceding that offset is located in the index.
26 The input file is positioned to the specified location in the index, and if
33 Another approach would be to generate the index on demand. In that case,
35 the index, but if a read far enough past the end of the index is required,
36 then further index entries would be generated and added.
43 Another way to build an index would be to use inflateCopy(). That would
47 index in a file.
76 /* Deallocate an index built by build_index() */
77 local void free_index(struct access *index)
79 if (index != NULL) {
80 free(index->list);
81 free(index);
87 local struct access *addpoint(struct access *index, int bits,
93 if (index == NULL) {
94 index = malloc(sizeof(struct access));
95 if (index == NULL) return NULL;
96 index->list = malloc(sizeof(struct point) << 3);
97 if (index->list == NULL) {
98 free(index);
101 index->size = 8;
102 index->have = 0;
106 else if (index->have == index->size) {
107 index->size <<= 1;
108 next = realloc(index->list, sizeof(struct point) * index->size);
110 free_index(index);
113 index->list = next;
117 next = index->list + index->have;
125 index->have++;
128 return index;
131 /* Make one entire pass through the compressed stream and build an index, with
138 file read error. On success, *built points to the resulting index. */
144 struct access *index; /* access points being generated */
159 /* inflate the input, maintain a sliding window, and build an index -- this
163 index = NULL; /* will be allocated by first addpoint() */
200 /* if at end of block, consider adding an index entry (note that if
206 index always has at least one access point; we avoid creating an
211 index = addpoint(index, strm.data_type & 7, totin,
213 if (index == NULL) {
222 /* clean up and return index (release unused entries in list) */
224 index = realloc(index, sizeof(struct point) * index->have);
225 index->size = index->have;
226 *built = index;
227 return index->size;
232 if (index != NULL)
233 free_index(index);
237 /* Use the index to read len bytes from offset into buf, return bytes read or
241 should not return a data error unless the file was modified since the index
244 local int extract(FILE *in, struct access *index, off_t offset,
258 here = index->list;
259 ret = index->have;
354 struct access *index = NULL;
368 /* build index */
369 len = build_index(in, SPAN, &index);
383 fprintf(stderr, "zran: error %d while building index\n", len);
387 fprintf(stderr, "zran: built index with %d access points\n", len);
389 /* use index by reading some bytes from an arbitrary offset */
390 offset = (index->list[index->have - 1].out << 1) / 3;
391 len = extract(in, index, offset, buf, CHUNK);
401 free_index(index);