aboutsummaryrefslogtreecommitdiff
path: root/src/big_int.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-07-11 16:10:04 +0100
committergingerBill <bill@gingerbill.org>2021-07-11 16:10:04 +0100
commite90e7d4af985b0b19e23f87e45b9add5aab98f69 (patch)
tree968eace8baf60613c069ed1064fbc3614ab902eb /src/big_int.cpp
parent460e14e5860a503b8e7716ce18a29eb99f517cf7 (diff)
Change `mp_clear` calls to `big_int_dealloc`
Diffstat (limited to 'src/big_int.cpp')
-rw-r--r--src/big_int.cpp41
1 files changed, 20 insertions, 21 deletions
diff --git a/src/big_int.cpp b/src/big_int.cpp
index f42c2e466..74683ef63 100644
--- a/src/big_int.cpp
+++ b/src/big_int.cpp
@@ -9,7 +9,6 @@
typedef mp_int BigInt;
-
void big_int_from_u64(BigInt *dst, u64 x);
void big_int_from_i64(BigInt *dst, i64 x);
void big_int_init (BigInt *dst, BigInt const *src);
@@ -265,14 +264,14 @@ void big_int_shr(BigInt *dst, BigInt const *x, BigInt const *y) {
u32 yy = mp_get_u32(y);
BigInt d = {};
mp_div_2d(x, yy, dst, &d);
- mp_clear(&d);
+ big_int_dealloc(&d);
}
void big_int_mul_u64(BigInt *dst, BigInt const *x, u64 y) {
BigInt d = {};
big_int_from_u64(&d, y);
mp_mul(x, &d, dst);
- mp_clear(&d);
+ big_int_dealloc(&d);
}
@@ -303,13 +302,13 @@ void big_int_quo_rem(BigInt const *x, BigInt const *y, BigInt *q_, BigInt *r_) {
void big_int_quo(BigInt *z, BigInt const *x, BigInt const *y) {
BigInt r = {};
big_int_quo_rem(x, y, z, &r);
- mp_clear(&r);
+ big_int_dealloc(&r);
}
void big_int_rem(BigInt *z, BigInt const *x, BigInt const *y) {
BigInt q = {};
big_int_quo_rem(x, y, &q, z);
- mp_clear(&q);
+ big_int_dealloc(&q);
}
void big_int_euclidean_mod(BigInt *z, BigInt const *x, BigInt const *y) {
@@ -355,9 +354,9 @@ void big_int_and_not(BigInt *dst, BigInt const *x, BigInt const *y) {
mp_complement(&y1, &ny1);
mp_and(&x1, &ny1, dst);
- mp_clear(&x1);
- mp_clear(&y1);
- mp_clear(&ny1);
+ big_int_dealloc(&x1);
+ big_int_dealloc(&y1);
+ big_int_dealloc(&ny1);
return;
}
@@ -365,7 +364,7 @@ void big_int_and_not(BigInt *dst, BigInt const *x, BigInt const *y) {
mp_complement(y, &ny);
mp_and(x, &ny, dst);
- mp_clear(&ny);
+ big_int_dealloc(&ny);
return;
}
@@ -379,9 +378,9 @@ void big_int_and_not(BigInt *dst, BigInt const *x, BigInt const *y) {
big_int_or(&z1, &x1, &y1);
mp_add_d(&z1, 1, dst);
- mp_clear(&x1);
- mp_clear(&y1);
- mp_clear(&z1);
+ big_int_dealloc(&x1);
+ big_int_dealloc(&y1);
+ big_int_dealloc(&z1);
return;
}
@@ -391,8 +390,8 @@ void big_int_and_not(BigInt *dst, BigInt const *x, BigInt const *y) {
mp_decr(&y1);
big_int_and(dst, &x1, &y1);
- mp_clear(&x1);
- mp_clear(&y1);
+ big_int_dealloc(&x1);
+ big_int_dealloc(&y1);
return;
}
@@ -442,13 +441,13 @@ void big_int_not(BigInt *dst, BigInt const *x, i32 bit_count, bool is_signed) {
big_int_and(&a, dst, &pmask_minus_one);
big_int_and(&b, dst, &pmask);
big_int_sub(dst, &a, &b);
- mp_clear(&a);
- mp_clear(&b);
+ big_int_dealloc(&a);
+ big_int_dealloc(&b);
}
- mp_clear(&pow2b);
- mp_clear(&mask);
- mp_clear(&v);
+ big_int_dealloc(&pow2b);
+ big_int_dealloc(&mask);
+ big_int_dealloc(&v);
}
@@ -499,8 +498,8 @@ String big_int_to_string(gbAllocator allocator, BigInt const *x, u64 base) {
digit = cast(u8)big_int_to_u64(&r);
array_add(&buf, digit_to_char(digit));
- mp_clear(&r);
- mp_clear(&b);
+ big_int_dealloc(&r);
+ big_int_dealloc(&b);
for (isize i = first_word_idx; i < buf.count/2; i++) {
isize j = buf.count + first_word_idx - i - 1;