diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/zran.c | 4 | ||||
-rw-r--r-- | examples/zran.h | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/examples/zran.c b/examples/zran.c index d313595..9c3e5dc 100644 --- a/examples/zran.c +++ b/examples/zran.c | |||
@@ -130,6 +130,10 @@ static struct deflate_index *add_point(struct deflate_index *index, int bits, | |||
130 | 130 | ||
131 | // See comments in zran.h. | 131 | // See comments in zran.h. |
132 | int deflate_index_build(FILE *in, off_t span, struct deflate_index **built) { | 132 | int deflate_index_build(FILE *in, off_t span, struct deflate_index **built) { |
133 | // If this returns with an error, any attempt to use the index will cleanly | ||
134 | // return an error. | ||
135 | *built = NULL; | ||
136 | |||
133 | // Set up inflation state. | 137 | // Set up inflation state. |
134 | z_stream strm = {0}; // inflate engine (gets fired up later) | 138 | z_stream strm = {0}; // inflate engine (gets fired up later) |
135 | unsigned char buf[CHUNK]; // input buffer | 139 | unsigned char buf[CHUNK]; // input buffer |
diff --git a/examples/zran.h b/examples/zran.h index ebf780d..8a332d6 100644 --- a/examples/zran.h +++ b/examples/zran.h | |||
@@ -30,7 +30,7 @@ struct deflate_index { | |||
30 | // the number of access points on success (>= 1), Z_MEM_ERROR for out of | 30 | // the number of access points on success (>= 1), Z_MEM_ERROR for out of |
31 | // memory, Z_BUF_ERROR for a premature end of input, Z_DATA_ERROR for a format | 31 | // memory, Z_BUF_ERROR for a premature end of input, Z_DATA_ERROR for a format |
32 | // or verification error in the input file, or Z_ERRNO for a file read error. | 32 | // or verification error in the input file, or Z_ERRNO for a file read error. |
33 | // On success, *built points to the resulting index. | 33 | // On success, *built points to the resulting index, otherwise it's NULL. |
34 | int deflate_index_build(FILE *in, off_t span, struct deflate_index **built); | 34 | int deflate_index_build(FILE *in, off_t span, struct deflate_index **built); |
35 | 35 | ||
36 | // Use the index to read len bytes from offset into buf. Return the number of | 36 | // Use the index to read len bytes from offset into buf. Return the number of |