mirror of
https://github.com/shadps4-emu/ext-zlib-ng.git
synced 2024-10-07 00:13:58 +00:00
Use MIN and MAX macros.
This commit is contained in:
parent
d7cac887af
commit
3f5801f151
@ -552,8 +552,8 @@ int32_t Z_EXPORT PREFIX(deflatePrime)(PREFIX3(stream) *strm, int32_t bits, int32
|
||||
return Z_BUF_ERROR;
|
||||
do {
|
||||
put = BIT_BUF_SIZE - s->bi_valid;
|
||||
if (put > bits)
|
||||
put = bits;
|
||||
put = MIN(put, bits);
|
||||
|
||||
if (s->bi_valid == 0)
|
||||
s->bi_buf = value64;
|
||||
else
|
||||
@ -1117,8 +1117,7 @@ int32_t Z_EXPORT PREFIX(deflateCopy)(PREFIX3(stream) *dest, PREFIX3(stream) *sou
|
||||
Z_INTERNAL unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size) {
|
||||
uint32_t len = strm->avail_in;
|
||||
|
||||
if (len > size)
|
||||
len = size;
|
||||
len = MIN(len, size);
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
|
@ -132,7 +132,7 @@ Z_INTERNAL block_state deflate_stored(deflate_state *s, int flush) {
|
||||
}
|
||||
s->block_start = (int)s->strstart;
|
||||
}
|
||||
s->high_water = MIN(s->high_water, s->strstart);
|
||||
s->high_water = MAX(s->high_water, s->strstart);
|
||||
|
||||
/* If the last block was written to next_out, then done. */
|
||||
if (last)
|
||||
@ -161,7 +161,7 @@ Z_INTERNAL block_state deflate_stored(deflate_state *s, int flush) {
|
||||
s->strstart += have;
|
||||
s->insert += MIN(have, s->w_size - s->insert);
|
||||
}
|
||||
s->high_water = MIN(s->high_water, s->strstart);
|
||||
s->high_water = MAX(s->high_water, s->strstart);
|
||||
|
||||
/* There was not enough avail_out to write a complete worthy or flushed
|
||||
* stored block to next_out. Write a stored block to pending instead, if we
|
||||
|
@ -210,8 +210,8 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in
|
||||
copy = state->length;
|
||||
PULL();
|
||||
ROOM();
|
||||
if (copy > have) copy = have;
|
||||
if (copy > left) copy = left;
|
||||
copy = MIN(copy, have);
|
||||
copy = MIN(copy, left);
|
||||
memcpy(put, next, copy);
|
||||
have -= copy;
|
||||
next += copy;
|
||||
@ -453,8 +453,7 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in
|
||||
from = put - state->offset;
|
||||
copy = left;
|
||||
}
|
||||
if (copy > state->length)
|
||||
copy = state->length;
|
||||
copy = MIN(copy, state->length);
|
||||
state->length -= copy;
|
||||
left -= copy;
|
||||
do {
|
||||
|
20
inflate.c
20
inflate.c
@ -657,8 +657,8 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) {
|
||||
/* copy stored block from input to output */
|
||||
copy = state->length;
|
||||
if (copy) {
|
||||
if (copy > have) copy = have;
|
||||
if (copy > left) copy = left;
|
||||
copy = MIN(copy, have);
|
||||
copy = MIN(copy, left);
|
||||
if (copy == 0) goto inf_leave;
|
||||
memcpy(put, next, copy);
|
||||
have -= copy;
|
||||
@ -928,10 +928,8 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) {
|
||||
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
||||
Trace((stderr, "inflate.c too far\n"));
|
||||
copy -= state->whave;
|
||||
if (copy > state->length)
|
||||
copy = state->length;
|
||||
if (copy > left)
|
||||
copy = left;
|
||||
copy = MIN(copy, state->length);
|
||||
copy = MIN(copy, left);
|
||||
left -= copy;
|
||||
state->length -= copy;
|
||||
do {
|
||||
@ -948,16 +946,12 @@ int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) {
|
||||
} else {
|
||||
from = state->window + (state->wnext - copy);
|
||||
}
|
||||
if (copy > state->length)
|
||||
copy = state->length;
|
||||
if (copy > left)
|
||||
copy = left;
|
||||
copy = MIN(copy, state->length);
|
||||
copy = MIN(copy, left);
|
||||
|
||||
put = functable.chunkcopy_safe(put, from, copy, put + left);
|
||||
} else { /* copy from output */
|
||||
copy = state->length;
|
||||
if (copy > left)
|
||||
copy = left;
|
||||
copy = MIN(state->length, left);
|
||||
|
||||
put = functable.chunkmemset_safe(put, state->offset, copy, left);
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ int Z_INTERNAL zng_inflate_table(codetype type, uint16_t *lens, unsigned codes,
|
||||
root = *bits;
|
||||
for (max = MAXBITS; max >= 1; max--)
|
||||
if (count[max] != 0) break;
|
||||
if (root > max) root = max;
|
||||
root = MIN(root, max);
|
||||
if (max == 0) { /* no symbols to code at all */
|
||||
here.op = (unsigned char)64; /* invalid code marker */
|
||||
here.bits = (unsigned char)1;
|
||||
@ -119,7 +119,7 @@ int Z_INTERNAL zng_inflate_table(codetype type, uint16_t *lens, unsigned codes,
|
||||
}
|
||||
for (min = 1; min < max; min++)
|
||||
if (count[min] != 0) break;
|
||||
if (root < min) root = min;
|
||||
root = MAX(root, min);
|
||||
|
||||
/* check for an over-subscribed or incomplete set of lengths */
|
||||
left = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user