Skip to content

Constify static data in fpconv.c #799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ext/json/ext/vendor/fpconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ typedef struct Fp {
int exp;
} Fp;

static Fp powers_ten[] = {
static const Fp powers_ten[] = {
{ 18054884314459144840U, -1220 }, { 13451937075301367670U, -1193 },
{ 10022474136428063862U, -1166 }, { 14934650266808366570U, -1140 },
{ 11127181549972568877U, -1113 }, { 16580792590934885855U, -1087 },
Expand Down Expand Up @@ -123,7 +123,7 @@ static Fp find_cachedpow10(int exp, int* k)
#define absv(n) ((n) < 0 ? -(n) : (n))
#define minv(a, b) ((a) < (b) ? (a) : (b))

static uint64_t tens[] = {
static const uint64_t tens[] = {
10000000000000000000U, 1000000000000000000U, 100000000000000000U,
10000000000000000U, 1000000000000000U, 100000000000000U,
10000000000000U, 1000000000000U, 100000000000U,
Expand Down Expand Up @@ -244,7 +244,7 @@ static int generate_digits(Fp* fp, Fp* upper, Fp* lower, char* digits, int* K)
uint64_t part2 = upper->frac & (one.frac - 1);

int idx = 0, kappa = 10;
uint64_t* divp;
const uint64_t* divp;
/* 1000000000 */
for(divp = tens + 10; kappa > 0; divp++) {

Expand All @@ -268,7 +268,7 @@ static int generate_digits(Fp* fp, Fp* upper, Fp* lower, char* digits, int* K)
}

/* 10 */
uint64_t* unit = tens + 18;
const uint64_t* unit = tens + 18;

while(true) {
part2 *= 10;
Expand Down
Loading