Skip to content

Commit 62e7ca5

Browse files
sergey-senozhatskytorvalds
authored andcommitted
zlib: clean up some dead code
Cleanup unused `if 0'-ed functions, which have been dead since 2006 (commits 87c2ce3 ("lib/zlib*: cleanups") by Adrian Bunk and 4f3865f ("zlib_inflate: Upgrade library code to a recent version") by Richard Purdie): - zlib_deflateSetDictionary - zlib_deflateParams - zlib_deflateCopy - zlib_inflateSync - zlib_syncsearch - zlib_inflateSetDictionary - zlib_inflatePrime Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 0f9859c commit 62e7ca5

3 files changed

Lines changed: 0 additions & 393 deletions

File tree

‎include/linux/zlib.h‎

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -493,64 +493,6 @@ extern int deflateInit2 (z_streamp strm,
493493
method). msg is set to null if there is no error message. deflateInit2 does
494494
not perform any compression: this will be done by deflate().
495495
*/
496-
497-
#if 0
498-
extern int zlib_deflateSetDictionary (z_streamp strm,
499-
const Byte *dictionary,
500-
uInt dictLength);
501-
#endif
502-
/*
503-
Initializes the compression dictionary from the given byte sequence
504-
without producing any compressed output. This function must be called
505-
immediately after deflateInit, deflateInit2 or deflateReset, before any
506-
call of deflate. The compressor and decompressor must use exactly the same
507-
dictionary (see inflateSetDictionary).
508-
509-
The dictionary should consist of strings (byte sequences) that are likely
510-
to be encountered later in the data to be compressed, with the most commonly
511-
used strings preferably put towards the end of the dictionary. Using a
512-
dictionary is most useful when the data to be compressed is short and can be
513-
predicted with good accuracy; the data can then be compressed better than
514-
with the default empty dictionary.
515-
516-
Depending on the size of the compression data structures selected by
517-
deflateInit or deflateInit2, a part of the dictionary may in effect be
518-
discarded, for example if the dictionary is larger than the window size in
519-
deflate or deflate2. Thus the strings most likely to be useful should be
520-
put at the end of the dictionary, not at the front.
521-
522-
Upon return of this function, strm->adler is set to the Adler32 value
523-
of the dictionary; the decompressor may later use this value to determine
524-
which dictionary has been used by the compressor. (The Adler32 value
525-
applies to the whole dictionary even if only a subset of the dictionary is
526-
actually used by the compressor.)
527-
528-
deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
529-
parameter is invalid (such as NULL dictionary) or the stream state is
530-
inconsistent (for example if deflate has already been called for this stream
531-
or if the compression method is bsort). deflateSetDictionary does not
532-
perform any compression: this will be done by deflate().
533-
*/
534-
535-
#if 0
536-
extern int zlib_deflateCopy (z_streamp dest, z_streamp source);
537-
#endif
538-
539-
/*
540-
Sets the destination stream as a complete copy of the source stream.
541-
542-
This function can be useful when several compression strategies will be
543-
tried, for example when there are several ways of pre-processing the input
544-
data with a filter. The streams that will be discarded should then be freed
545-
by calling deflateEnd. Note that deflateCopy duplicates the internal
546-
compression state which can be quite large, so this strategy is slow and
547-
can consume lots of memory.
548-
549-
deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
550-
enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
551-
(such as zalloc being NULL). msg is left unchanged in both source and
552-
destination.
553-
*/
554496

555497
extern int zlib_deflateReset (z_streamp strm);
556498
/*
@@ -568,27 +510,6 @@ static inline unsigned long deflateBound(unsigned long s)
568510
return s + ((s + 7) >> 3) + ((s + 63) >> 6) + 11;
569511
}
570512

571-
#if 0
572-
extern int zlib_deflateParams (z_streamp strm, int level, int strategy);
573-
#endif
574-
/*
575-
Dynamically update the compression level and compression strategy. The
576-
interpretation of level and strategy is as in deflateInit2. This can be
577-
used to switch between compression and straight copy of the input data, or
578-
to switch to a different kind of input data requiring a different
579-
strategy. If the compression level is changed, the input available so far
580-
is compressed with the old level (and may be flushed); the new level will
581-
take effect only at the next call of deflate().
582-
583-
Before the call of deflateParams, the stream state must be set as for
584-
a call of deflate(), since the currently available input may have to
585-
be compressed and flushed. In particular, strm->avail_out must be non-zero.
586-
587-
deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
588-
stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
589-
if strm->avail_out was zero.
590-
*/
591-
592513
/*
593514
extern int inflateInit2 (z_streamp strm, int windowBits);
594515
@@ -631,45 +552,6 @@ extern int inflateInit2 (z_streamp strm, int windowBits);
631552
and avail_out are unchanged.)
632553
*/
633554

634-
extern int zlib_inflateSetDictionary (z_streamp strm,
635-
const Byte *dictionary,
636-
uInt dictLength);
637-
/*
638-
Initializes the decompression dictionary from the given uncompressed byte
639-
sequence. This function must be called immediately after a call of inflate,
640-
if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
641-
can be determined from the adler32 value returned by that call of inflate.
642-
The compressor and decompressor must use exactly the same dictionary (see
643-
deflateSetDictionary). For raw inflate, this function can be called
644-
immediately after inflateInit2() or inflateReset() and before any call of
645-
inflate() to set the dictionary. The application must insure that the
646-
dictionary that was used for compression is provided.
647-
648-
inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
649-
parameter is invalid (such as NULL dictionary) or the stream state is
650-
inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
651-
expected one (incorrect adler32 value). inflateSetDictionary does not
652-
perform any decompression: this will be done by subsequent calls of
653-
inflate().
654-
*/
655-
656-
#if 0
657-
extern int zlib_inflateSync (z_streamp strm);
658-
#endif
659-
/*
660-
Skips invalid compressed data until a full flush point (see above the
661-
description of deflate with Z_FULL_FLUSH) can be found, or until all
662-
available input is skipped. No output is provided.
663-
664-
inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
665-
if no more input was provided, Z_DATA_ERROR if no flush point has been found,
666-
or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
667-
case, the application may save the current current value of total_in which
668-
indicates where valid compressed data was found. In the error case, the
669-
application may repeatedly call inflateSync, providing more input each time,
670-
until success or end of the input data.
671-
*/
672-
673555
extern int zlib_inflateReset (z_streamp strm);
674556
/*
675557
This function is equivalent to inflateEnd followed by inflateInit,

‎lib/zlib_deflate/deflate.c‎

Lines changed: 0 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -249,52 +249,6 @@ int zlib_deflateInit2(
249249
return zlib_deflateReset(strm);
250250
}
251251

252-
/* ========================================================================= */
253-
#if 0
254-
int zlib_deflateSetDictionary(
255-
z_streamp strm,
256-
const Byte *dictionary,
257-
uInt dictLength
258-
)
259-
{
260-
deflate_state *s;
261-
uInt length = dictLength;
262-
uInt n;
263-
IPos hash_head = 0;
264-
265-
if (strm == NULL || strm->state == NULL || dictionary == NULL)
266-
return Z_STREAM_ERROR;
267-
268-
s = (deflate_state *) strm->state;
269-
if (s->status != INIT_STATE) return Z_STREAM_ERROR;
270-
271-
strm->adler = zlib_adler32(strm->adler, dictionary, dictLength);
272-
273-
if (length < MIN_MATCH) return Z_OK;
274-
if (length > MAX_DIST(s)) {
275-
length = MAX_DIST(s);
276-
#ifndef USE_DICT_HEAD
277-
dictionary += dictLength - length; /* use the tail of the dictionary */
278-
#endif
279-
}
280-
memcpy((char *)s->window, dictionary, length);
281-
s->strstart = length;
282-
s->block_start = (long)length;
283-
284-
/* Insert all strings in the hash table (except for the last two bytes).
285-
* s->lookahead stays null, so s->ins_h will be recomputed at the next
286-
* call of fill_window.
287-
*/
288-
s->ins_h = s->window[0];
289-
UPDATE_HASH(s, s->ins_h, s->window[1]);
290-
for (n = 0; n <= length - MIN_MATCH; n++) {
291-
INSERT_STRING(s, n, hash_head);
292-
}
293-
if (hash_head) hash_head = 0; /* to make compiler happy */
294-
return Z_OK;
295-
}
296-
#endif /* 0 */
297-
298252
/* ========================================================================= */
299253
int zlib_deflateReset(
300254
z_streamp strm
@@ -326,45 +280,6 @@ int zlib_deflateReset(
326280
return Z_OK;
327281
}
328282

329-
/* ========================================================================= */
330-
#if 0
331-
int zlib_deflateParams(
332-
z_streamp strm,
333-
int level,
334-
int strategy
335-
)
336-
{
337-
deflate_state *s;
338-
compress_func func;
339-
int err = Z_OK;
340-
341-
if (strm == NULL || strm->state == NULL) return Z_STREAM_ERROR;
342-
s = (deflate_state *) strm->state;
343-
344-
if (level == Z_DEFAULT_COMPRESSION) {
345-
level = 6;
346-
}
347-
if (level < 0 || level > 9 || strategy < 0 || strategy > Z_HUFFMAN_ONLY) {
348-
return Z_STREAM_ERROR;
349-
}
350-
func = configuration_table[s->level].func;
351-
352-
if (func != configuration_table[level].func && strm->total_in != 0) {
353-
/* Flush the last buffer: */
354-
err = zlib_deflate(strm, Z_PARTIAL_FLUSH);
355-
}
356-
if (s->level != level) {
357-
s->level = level;
358-
s->max_lazy_match = configuration_table[level].max_lazy;
359-
s->good_match = configuration_table[level].good_length;
360-
s->nice_match = configuration_table[level].nice_length;
361-
s->max_chain_length = configuration_table[level].max_chain;
362-
}
363-
s->strategy = strategy;
364-
return err;
365-
}
366-
#endif /* 0 */
367-
368283
/* =========================================================================
369284
* Put a short in the pending buffer. The 16-bit value is put in MSB order.
370285
* IN assertion: the stream state is correct and there is enough room in
@@ -568,64 +483,6 @@ int zlib_deflateEnd(
568483
return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
569484
}
570485

571-
/* =========================================================================
572-
* Copy the source state to the destination state.
573-
*/
574-
#if 0
575-
int zlib_deflateCopy (
576-
z_streamp dest,
577-
z_streamp source
578-
)
579-
{
580-
#ifdef MAXSEG_64K
581-
return Z_STREAM_ERROR;
582-
#else
583-
deflate_state *ds;
584-
deflate_state *ss;
585-
ush *overlay;
586-
deflate_workspace *mem;
587-
588-
589-
if (source == NULL || dest == NULL || source->state == NULL) {
590-
return Z_STREAM_ERROR;
591-
}
592-
593-
ss = (deflate_state *) source->state;
594-
595-
*dest = *source;
596-
597-
mem = (deflate_workspace *) dest->workspace;
598-
599-
ds = &(mem->deflate_memory);
600-
601-
dest->state = (struct internal_state *) ds;
602-
*ds = *ss;
603-
ds->strm = dest;
604-
605-
ds->window = (Byte *) mem->window_memory;
606-
ds->prev = (Pos *) mem->prev_memory;
607-
ds->head = (Pos *) mem->head_memory;
608-
overlay = (ush *) mem->overlay_memory;
609-
ds->pending_buf = (uch *) overlay;
610-
611-
memcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
612-
memcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos));
613-
memcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos));
614-
memcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
615-
616-
ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
617-
ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush);
618-
ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize;
619-
620-
ds->l_desc.dyn_tree = ds->dyn_ltree;
621-
ds->d_desc.dyn_tree = ds->dyn_dtree;
622-
ds->bl_desc.dyn_tree = ds->bl_tree;
623-
624-
return Z_OK;
625-
#endif
626-
}
627-
#endif /* 0 */
628-
629486
/* ===========================================================================
630487
* Read a new buffer from the current input stream, update the adler32
631488
* and total number of bytes read. All deflate() input goes through

0 commit comments

Comments
 (0)