aboutsummaryrefslogtreecommitdiff
path: root/inflate.c
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2011-10-07 01:57:07 -0700
committerMark Adler <madler@alumni.caltech.edu>2011-10-07 02:11:56 -0700
commitf442c1e89e99ae5a0068a2d32e7284c2623f09fd (patch)
tree1bc659f486af707673c36916c4d75ef7f517dece /inflate.c
parent518ad0177ae2f1aaefc49285b3536a6bd8d9973c (diff)
downloadzlib-f442c1e89e99ae5a0068a2d32e7284c2623f09fd.tar.gz
zlib-f442c1e89e99ae5a0068a2d32e7284c2623f09fd.tar.bz2
zlib-f442c1e89e99ae5a0068a2d32e7284c2623f09fd.zip
Add a ./config --solo option to make zlib subset with no libary use
A common request has been the ability to compile zlib to require no other libraries. This --solo option provides that ability. The price is that the gz*, compress*, and uncompress functions are eliminated, and that the user must provide memory allocation and free routines to deflate and inflate when initializing.
Diffstat (limited to 'inflate.c')
-rw-r--r--inflate.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/inflate.c b/inflate.c
index dd880c4..cf10b01 100644
--- a/inflate.c
+++ b/inflate.c
@@ -180,10 +180,19 @@ int stream_size;
180 if (strm == Z_NULL) return Z_STREAM_ERROR; 180 if (strm == Z_NULL) return Z_STREAM_ERROR;
181 strm->msg = Z_NULL; /* in case we return an error */ 181 strm->msg = Z_NULL; /* in case we return an error */
182 if (strm->zalloc == (alloc_func)0) { 182 if (strm->zalloc == (alloc_func)0) {
183#ifdef Z_SOLO
184 return Z_STREAM_ERROR;
185#else
183 strm->zalloc = zcalloc; 186 strm->zalloc = zcalloc;
184 strm->opaque = (voidpf)0; 187 strm->opaque = (voidpf)0;
188#endif
185 } 189 }
186 if (strm->zfree == (free_func)0) strm->zfree = zcfree; 190 if (strm->zfree == (free_func)0)
191#ifdef Z_SOLO
192 return Z_STREAM_ERROR;
193#else
194 strm->zfree = zcfree;
195#endif
187 state = (struct inflate_state FAR *) 196 state = (struct inflate_state FAR *)
188 ZALLOC(strm, 1, sizeof(struct inflate_state)); 197 ZALLOC(strm, 1, sizeof(struct inflate_state));
189 if (state == Z_NULL) return Z_MEM_ERROR; 198 if (state == Z_NULL) return Z_MEM_ERROR;
@@ -1433,8 +1442,8 @@ z_streamp source;
1433 } 1442 }
1434 1443
1435 /* copy state */ 1444 /* copy state */
1436 zmemcpy(dest, source, sizeof(z_stream)); 1445 zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
1437 zmemcpy(copy, state, sizeof(struct inflate_state)); 1446 zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
1438 if (state->lencode >= state->codes && 1447 if (state->lencode >= state->codes &&
1439 state->lencode <= state->codes + ENOUGH - 1) { 1448 state->lencode <= state->codes + ENOUGH - 1) {
1440 copy->lencode = copy->codes + (state->lencode - state->codes); 1449 copy->lencode = copy->codes + (state->lencode - state->codes);