summaryrefslogtreecommitdiff
path: root/deflate.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 /deflate.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 'deflate.c')
-rw-r--r--deflate.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/deflate.c b/deflate.c
index b126a71..4b8e91b 100644
--- a/deflate.c
+++ b/deflate.c
@@ -235,10 +235,19 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
235 235
236 strm->msg = Z_NULL; 236 strm->msg = Z_NULL;
237 if (strm->zalloc == (alloc_func)0) { 237 if (strm->zalloc == (alloc_func)0) {
238#ifdef Z_SOLO
239 return Z_STREAM_ERROR;
240#else
238 strm->zalloc = zcalloc; 241 strm->zalloc = zcalloc;
239 strm->opaque = (voidpf)0; 242 strm->opaque = (voidpf)0;
243#endif
240 } 244 }
241 if (strm->zfree == (free_func)0) strm->zfree = zcfree; 245 if (strm->zfree == (free_func)0)
246#ifdef Z_SOLO
247 return Z_STREAM_ERROR;
248#else
249 strm->zfree = zcfree;
250#endif
242 251
243#ifdef FASTEST 252#ifdef FASTEST
244 if (level != 0) level = 1; 253 if (level != 0) level = 1;
@@ -957,12 +966,12 @@ int ZEXPORT deflateCopy (dest, source)
957 966
958 ss = source->state; 967 ss = source->state;
959 968
960 zmemcpy(dest, source, sizeof(z_stream)); 969 zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
961 970
962 ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); 971 ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
963 if (ds == Z_NULL) return Z_MEM_ERROR; 972 if (ds == Z_NULL) return Z_MEM_ERROR;
964 dest->state = (struct internal_state FAR *) ds; 973 dest->state = (struct internal_state FAR *) ds;
965 zmemcpy(ds, ss, sizeof(deflate_state)); 974 zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state));
966 ds->strm = dest; 975 ds->strm = dest;
967 976
968 ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); 977 ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
@@ -978,8 +987,8 @@ int ZEXPORT deflateCopy (dest, source)
978 } 987 }
979 /* following zmemcpy do not work for 16-bit MSDOS */ 988 /* following zmemcpy do not work for 16-bit MSDOS */
980 zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); 989 zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
981 zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos)); 990 zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
982 zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos)); 991 zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
983 zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); 992 zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
984 993
985 ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); 994 ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);