compat: drop `uncompress2()` compatibility shim
Our compat library has an implementation of zlib's `uncompress2()` function that gets used when linking against an old version of zlib that doesn't yet have it. The last user of `uncompress2()` got removed in 15a60b747e (reftable/block: open-code call to `uncompress2()`, 2024-04-08), so the compatibility code is not required anymore. Drop it. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Jan 28, 2025 at 09:41 UTC
3656d57bbf4d82b62f368d56d3c4703f3916c2dc
4 files changed
-107
Makefile
-1
@@ -984,7 +984,6 @@ LIB_OBJS += commit.o
984
LIB_OBJS += compat/nonblock.o
985
LIB_OBJS += compat/obstack.o
986
LIB_OBJS += compat/terminal.o
987
-LIB_OBJS += compat/zlib-uncompress2.o
987
LIB_OBJS += config.o
988
LIB_OBJS += connect.o
989
LIB_OBJS += connected.o
compat/zlib-uncompress2.c
deleted
-96
@@ -1,96 +0,0 @@
1
-#include "git-compat-util.h"
2
-
3
-#if ZLIB_VERNUM < 0x1290
4
-/* taken from zlib's uncompr.c
5
-
6
- commit cacf7f1d4e3d44d871b605da3b647f07d718623f
7
- Author: Mark Adler <madler@alumni.caltech.edu>
8
- Date: Sun Jan 15 09:18:46 2017 -0800
9
-
10
- zlib 1.2.11
11
-
12
-*/
13
-
14
-/*
15
- * Copyright (C) 1995-2003, 2010, 2014, 2016 Jean-loup Gailly, Mark Adler
16
- * For conditions of distribution and use, see copyright notice in zlib.h
17
- */
18
-
19
-/* clang-format off */
20
-
21
-/* ===========================================================================
22
- Decompresses the source buffer into the destination buffer. *sourceLen is
23
- the byte length of the source buffer. Upon entry, *destLen is the total size
24
- of the destination buffer, which must be large enough to hold the entire
25
- uncompressed data. (The size of the uncompressed data must have been saved
26
- previously by the compressor and transmitted to the decompressor by some
27
- mechanism outside the scope of this compression library.) Upon exit,
28
- *destLen is the size of the decompressed data and *sourceLen is the number
29
- of source bytes consumed. Upon return, source + *sourceLen points to the
30
- first unused input byte.
31
-
32
- uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough
33
- memory, Z_BUF_ERROR if there was not enough room in the output buffer, or
34
- Z_DATA_ERROR if the input data was corrupted, including if the input data is
35
- an incomplete zlib stream.
36
-*/
37
-int ZEXPORT uncompress2 (
38
- Bytef *dest,
39
- uLongf *destLen,
40
- const Bytef *source,
41
- uLong *sourceLen) {
42
- z_stream stream;
43
- int err;
44
- const uInt max = (uInt)-1;
45
- uLong len, left;
46
- Byte buf[1]; /* for detection of incomplete stream when *destLen == 0 */
47
-
48
- len = *sourceLen;
49
- if (*destLen) {
50
- left = *destLen;
51
- *destLen = 0;
52
- }
53
- else {
54
- left = 1;
55
- dest = buf;
56
- }
57
-
58
- stream.next_in = (z_const Bytef *)source;
59
- stream.avail_in = 0;
60
- stream.zalloc = (alloc_func)0;
61
- stream.zfree = (free_func)0;
62
- stream.opaque = (voidpf)0;
63
-
64
- err = inflateInit(&stream);
65
- if (err != Z_OK) return err;
66
-
67
- stream.next_out = dest;
68
- stream.avail_out = 0;
69
-
70
- do {
71
- if (stream.avail_out == 0) {
72
- stream.avail_out = left > (uLong)max ? max : (uInt)left;
73
- left -= stream.avail_out;
74
- }
75
- if (stream.avail_in == 0) {
76
- stream.avail_in = len > (uLong)max ? max : (uInt)len;
77
- len -= stream.avail_in;
78
- }
79
- err = inflate(&stream, Z_NO_FLUSH);
80
- } while (err == Z_OK);
81
-
82
- *sourceLen -= len + stream.avail_in;
83
- if (dest != buf)
84
- *destLen = stream.total_out;
85
- else if (stream.total_out && err == Z_BUF_ERROR)
86
- left = 1;
87
-
88
- inflateEnd(&stream);
89
- return err == Z_STREAM_END ? Z_OK :
90
- err == Z_NEED_DICT ? Z_DATA_ERROR :
91
- err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR :
92
- err;
93
-}
94
-#else
95
-static void *dummy_variable = &dummy_variable;
96
-#endif
git-compat-util.h
-9
@@ -1540,15 +1540,6 @@ int common_exit(const char *file, int line, int code);
1540
#define z_const
1541
#include <zlib.h>
1542
1543
-#if ZLIB_VERNUM < 0x1290
1544
-/*
1545
- * This is uncompress2, which is only available in zlib >= 1.2.9
1546
- * (released as of early 2017). See compat/zlib-uncompress2.c.
1547
- */
1548
-int uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source,
1549
- uLong *sourceLen);
1550
-#endif
1551
-
1543
/*
1544
* This include must come after system headers, since it introduces macros that
1545
* replace system names.
meson.build
-1
@@ -263,7 +263,6 @@ libgit_sources = [
263
'compat/nonblock.c',
264
'compat/obstack.c',
265
'compat/terminal.c',
266
- 'compat/zlib-uncompress2.c',
266
'config.c',
267
'connect.c',
268
'connected.c',