Avoid use of uintmax_t in enough.c.
This commit is contained in:
parent
3f44e55d5d
commit
164b8e3c9f
@ -1,7 +1,7 @@
|
|||||||
/* enough.c -- determine the maximum size of inflate's Huffman code tables over
|
/* enough.c -- determine the maximum size of inflate's Huffman code tables over
|
||||||
* all possible valid and complete prefix codes, subject to a length limit.
|
* all possible valid and complete prefix codes, subject to a length limit.
|
||||||
* Copyright (C) 2007, 2008, 2012, 2018 Mark Adler
|
* Copyright (C) 2007, 2008, 2012, 2018, 2024 Mark Adler
|
||||||
* Version 1.5 5 August 2018 Mark Adler
|
* Version 1.6 29 July 2024 Mark Adler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Version history:
|
/* Version history:
|
||||||
@ -19,6 +19,7 @@
|
|||||||
Clean up code indentation
|
Clean up code indentation
|
||||||
1.5 5 Aug 2018 Clean up code style, formatting, and comments
|
1.5 5 Aug 2018 Clean up code style, formatting, and comments
|
||||||
Show all the codes for the maximum, and only the maximum
|
Show all the codes for the maximum, and only the maximum
|
||||||
|
1.6 29 Jul 2024 Avoid use of uintmax_t
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -88,33 +89,32 @@
|
|||||||
need to be examined to cover all of the possible table memory usage cases
|
need to be examined to cover all of the possible table memory usage cases
|
||||||
for the default arguments of 286 symbols limited to 15-bit codes.
|
for the default arguments of 286 symbols limited to 15-bit codes.
|
||||||
|
|
||||||
Note that the uintmax_t type is used for counting. It is quite easy to
|
Note that unsigned long long is used for counting. It is quite easy to
|
||||||
exceed the capacity of an eight-byte integer with a large number of symbols
|
exceed the capacity of an eight-byte integer with a large number of symbols
|
||||||
and a large maximum code length, so multiple-precision arithmetic would need
|
and a large maximum code length, so multiple-precision arithmetic would need
|
||||||
to replace the integer arithmetic in that case. This program will abort if
|
to replace the integer arithmetic in that case. This program will abort if
|
||||||
an overflow occurs. The big_t type identifies where the counting takes
|
an overflow occurs. The big_t type identifies where the counting takes
|
||||||
place.
|
place.
|
||||||
|
|
||||||
The uintmax_t type is also used for calculating the number of possible codes
|
The unsigned long long type is also used for calculating the number of
|
||||||
remaining at the maximum length. This limits the maximum code length to the
|
possible codes remaining at the maximum length. This limits the maximum code
|
||||||
number of bits in a long long minus the number of bits needed to represent
|
length to the number of bits in a long long minus the number of bits needed
|
||||||
the symbols in a flat code. The code_t type identifies where the bit-pattern
|
to represent the symbols in a flat code. The code_t type identifies where
|
||||||
counting takes place.
|
the bit-pattern counting takes place.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdint.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#define local static
|
#define local static
|
||||||
|
|
||||||
// Special data types.
|
// Special data types.
|
||||||
typedef uintmax_t big_t; // type for code counting
|
typedef unsigned long long big_t; // type for code counting
|
||||||
#define PRIbig "ju" // printf format for big_t
|
#define PRIbig "llu" // printf format for big_t
|
||||||
typedef uintmax_t code_t; // type for bit pattern counting
|
typedef big_t code_t; // type for bit pattern counting
|
||||||
struct tab { // type for been-here check
|
struct tab { // type for been-here check
|
||||||
size_t len; // allocated length of bit vector in octets
|
size_t len; // allocated length of bit vector in octets
|
||||||
char *vec; // allocated bit vector
|
char *vec; // allocated bit vector
|
||||||
|
Loading…
Reference in New Issue
Block a user