Commit c68d46a for zlib
commit c68d46a55f7b5d2097b8d8a364bdb5f2d667eba3
Author: Mark Adler <git@madler.net>
Date: Thu Mar 26 15:27:13 2026 -0700
Make skipset functions static (not external) in minizip.
diff --git a/contrib/minizip/skipset.h b/contrib/minizip/skipset.h
index 3878bcf..34e2443 100644
--- a/contrib/minizip/skipset.h
+++ b/contrib/minizip/skipset.h
@@ -80,17 +80,17 @@ typedef struct {
} set_rand_t;
/* --private-- Initialize the state *gen using seed and seq. seed seeds the
// advancing 64-bit state. seq is a sequence selection constant. */
-void set_seed(set_rand_t *gen, ui64_t seed, ui64_t seq) {
+static void set_seed(set_rand_t *gen, ui64_t seed, ui64_t seq) {
gen->inc = (seq << 1) | 1;
gen->state = (seed + gen->inc) * 6364136223846793005ULL + gen->inc;
}
/* Start a unique random number sequence using bits from noise sources. */
-void set_uniq(set_rand_t *gen, const void *ptr) {
+static void set_uniq(set_rand_t *gen, const void *ptr) {
set_seed(gen, ((ui64_t)(ptrdiff_t)ptr << 32) ^
((ui64_t)time(NULL) << 12) ^ clock(), 0);
}
/* Return 32 random bits, advancing the state *gen. */
-ui32_t set_rand(set_rand_t *gen) {
+static ui32_t set_rand(set_rand_t *gen) {
ui32_t mix;
int rot;
ui64_t state = gen->state;
@@ -152,7 +152,7 @@ typedef struct set_s {
# define SET_ALLOC_SIZE(ptr) 0
# endif
// With tracking.
-void *set_alloc(set_t *set, void *ptr, size_t size) {
+static void *set_alloc(set_t *set, void *ptr, size_t size) {
size_t had = ptr == NULL ? 0 : SET_ALLOC_SIZE(ptr);
void *mem = realloc(ptr, size);
if (mem == NULL)
@@ -161,7 +161,7 @@ void *set_alloc(set_t *set, void *ptr, size_t size) {
set->memory += SET_ALLOC_SIZE(mem) - had;
return mem;
}
-void set_free(set_t *set, void *ptr) {
+static void set_free(set_t *set, void *ptr) {
if (ptr != NULL) {
set->allocs--;
set->memory -= SET_ALLOC_SIZE(ptr);
@@ -170,13 +170,13 @@ void set_free(set_t *set, void *ptr) {
}
#else
/* Without tracking. */
-void *set_alloc(set_t *set, void *ptr, size_t size) {
+static void *set_alloc(set_t *set, void *ptr, size_t size) {
void *mem = realloc(ptr, size);
if (mem == NULL)
longjmp(set->env, ENOMEM);
return mem;
}
-void set_free(set_t *set, void *ptr) {
+static void set_free(set_t *set, void *ptr) {
(void)set;
free(ptr);
}
@@ -186,7 +186,7 @@ void set_free(set_t *set, void *ptr) {
// want links. If fill is true, assure that the first want links are filled in,
// setting them to set->head if not previously filled in. Otherwise it is
// assumed that the first want links are about to be filled in. */
-void set_grow(set_t *set, set_node_t *node, int want, int fill) {
+static void set_grow(set_t *set, set_node_t *node, int want, int fill) {
int i;
if (node->size < want) {
int more = node->size ? node->size : 1;
@@ -203,7 +203,7 @@ void set_grow(set_t *set, set_node_t *node, int want, int fill) {
}
/* --private-- Return a new node. key is left uninitialized. */
-set_node_t *set_node(set_t *set) {
+static set_node_t *set_node(set_t *set) {
set_node_t *node = set_alloc(set, NULL, sizeof(set_node_t));
node->size = 0;
node->fill = 0;
@@ -212,7 +212,7 @@ set_node_t *set_node(set_t *set) {
}
/* --private-- Free the list linked from head, along with the keys. */
-void set_sweep(set_t *set) {
+static void set_sweep(set_t *set) {
set_node_t *step = set->head->right[0];
while (step != set->head) {
set_node_t *next = step->right[0]; /* save link to next node */
@@ -229,7 +229,7 @@ void set_sweep(set_t *set) {
// errno.h.) The set can still be used if this happens, assuming that it didn't
// happen during set_start(). Whether set_start() completed or not, set_end()
// can be used to free the set's memory after a longjmp(). */
-void set_start(set_t *set) {
+SKIPSET_EXPORT void set_start(set_t *set) {
#ifdef SET_TRACK
set->allocs = 0;
set->memory = 0;
@@ -246,15 +246,16 @@ void set_start(set_t *set) {
/* Return true if *set appears to be in a usable state. If *set has been zeroed
// out, then set_ok(set) will be false and set_end(set) will be safe. */
-int set_ok(set_t *set) {
+SKIPSET_EXPORT int set_ok(set_t *set) {
return set->head != NULL &&
set->head->right != NULL &&
*(unsigned char *)&set->head->key == 137;
}
+#if 0 /* not used in minizip */
/* Empty the set. This frees the memory used for the previous set contents.
// After set_clear(), *set is ready for use, as if after a set_start(). */
-void set_clear(set_t *set) {
+SKIPSET_EXPORT void set_clear(set_t *set) {
assert(set_ok(set) && "improper use");
/* Free all the keys and their nodes. */
@@ -267,12 +268,13 @@ void set_clear(set_t *set) {
set->path->fill = 0;
set->depth = 0;
}
+#endif
/* Done using the set -- free all allocations. The only operation on *set
// permitted after this is set_start(). Though another set_end() would do no
// harm. This can be done at any time after a set_start(), or after a longjmp()
// on any allocation failure, including during a set_start(). */
-void set_end(set_t *set) {
+SKIPSET_EXPORT void set_end(set_t *set) {
if (set->head != NULL) {
/* Empty the set and free the head node. */
if (set->head->right != NULL) {
@@ -299,7 +301,7 @@ void set_end(set_t *set) {
/* Look for key. Return 1 if found or 0 if not. This also puts the path to get
// there in set->path, for use by set_insert(). */
-int set_found(set_t *set, set_key_t key) {
+SKIPSET_EXPORT int set_found(set_t *set, set_key_t key) {
set_node_t *head, *here;
int i;
assert(set_ok(set) && "improper use");
@@ -322,7 +324,7 @@ int set_found(set_t *set, set_key_t key) {
}
/* Insert the key key. Return 0 on success, or 1 if key is already in the set. */
-int set_insert(set_t *set, set_key_t key) {
+SKIPSET_EXPORT int set_insert(set_t *set, set_key_t key) {
int level = 0;
int bit;
int i;
diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c
index 136c048..03424ab 100644
--- a/contrib/minizip/zip.c
+++ b/contrib/minizip/zip.c
@@ -129,6 +129,7 @@ typedef struct linkedlist_data_s
/* zipAlreadyThere() set functions for a set of zero-terminated strings, and
// a block_t type for reading the central directory datablocks. */
+#define SKIPSET_EXPORT static
typedef char *set_key_t;
#define set_cmp(a, b) strcmp(a, b)
#define set_drop(s, k) set_free(s, k)