Home | History | Annotate | Download | only in examples

Lines Matching defs:access

1 /* zran.c -- example of zlib/gzip stream indexing and random access
12 for random access of a compressed file. A file containing a zlib or gzip
14 its entirety, and an index built with access points about every SPAN bytes
19 An access point can be created at the start of any deflate block, by saving
26 a new access point. If so, that point is saved in a data structure that
39 requests for random access reads from the compressed data would try to use
44 access, mainly copying the 32K byte dictionary. So if small pieces of the
49 not be constrained to have access points at block boundaries, but requires
50 more memory per access point, and also cannot be saved to file due to the
62 #define SPAN 1048576L /* desired distance between access points */
66 /* access point entry */
74 /* access point list */
75 struct access {
82 local void free_index(struct access *index)
90 /* Add an entry to the access point list. If out of memory, deallocate the
92 local struct access *addpoint(struct access *index, int bits,
99 index = malloc(sizeof(struct access));
137 access points about every span bytes of uncompressed output -- span is
138 chosen to balance the speed of random access against the memory requirements
139 of the list, about 32K bytes per access point. Note that data after the end
141 returns the number of access points on success (>= 1), Z_MEM_ERROR for out
144 local int build_index(FILE *in, off_t span, struct access **built)
148 off_t last; /* totout value of last access point */
149 struct access *index; /* access points being generated */
211 index always has at least one access point; we avoid creating an
212 access point after the last block by checking bit 6 of data_type
249 local int extract(FILE *in, struct access *index, off_t offset,
359 struct access *index = NULL;
392 fprintf(stderr, "zran: built index with %d access points\n", len);