diff options
| author | Michael Dusan <michael.dusan@gmail.com> | 2020-02-10 23:08:33 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-10 23:08:33 -0500 |
| commit | e624c862894ec50998aafb3026d4ed45208acd6d (patch) | |
| tree | a01d54c8d5ba3178eaed1fa8d0ef9c081d95d9f2 /src/bigint.cpp | |
| parent | 26183660558c43133d862912c602e316f43698c7 (diff) | |
| parent | edb210905dcbe666fa5222bceacd2e5bdb16bb89 (diff) | |
| download | zig-e624c862894ec50998aafb3026d4ed45208acd6d.tar.gz zig-e624c862894ec50998aafb3026d4ed45208acd6d.zip | |
Merge pull request #4389 from mikdusan/stage1-mem
stage1: memory/report overhaul
Diffstat (limited to 'src/bigint.cpp')
| -rw-r--r-- | src/bigint.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/bigint.cpp b/src/bigint.cpp index 1127033d02..644e25837e 100644 --- a/src/bigint.cpp +++ b/src/bigint.cpp @@ -93,7 +93,7 @@ static void to_twos_complement(BigInt *dest, const BigInt *op, size_t bit_count) if (dest->data.digit == 0) dest->digit_count = 0; return; } - dest->data.digits = allocate_nonzero<uint64_t>(dest->digit_count); + dest->data.digits = heap::c_allocator.allocate_nonzero<uint64_t>(dest->digit_count); for (size_t i = 0; i < digits_to_copy; i += 1) { uint64_t digit = (i < op->digit_count) ? op_digits[i] : 0; dest->data.digits[i] = digit; @@ -174,7 +174,7 @@ void bigint_init_data(BigInt *dest, const uint64_t *digits, size_t digit_count, dest->digit_count = digit_count; dest->is_negative = is_negative; - dest->data.digits = allocate_nonzero<uint64_t>(digit_count); + dest->data.digits = heap::c_allocator.allocate_nonzero<uint64_t>(digit_count); memcpy(dest->data.digits, digits, sizeof(uint64_t) * digit_count); bigint_normalize(dest); @@ -191,13 +191,13 @@ void bigint_init_bigint(BigInt *dest, const BigInt *src) { } dest->is_negative = src->is_negative; dest->digit_count = src->digit_count; - dest->data.digits = allocate_nonzero<uint64_t>(dest->digit_count); + dest->data.digits = heap::c_allocator.allocate_nonzero<uint64_t>(dest->digit_count); memcpy(dest->data.digits, src->data.digits, sizeof(uint64_t) * dest->digit_count); } void bigint_deinit(BigInt *bi) { if (bi->digit_count > 1) - deallocate<uint64_t>(bi->data.digits, bi->digit_count); + heap::c_allocator.deallocate(bi->data.digits, bi->digit_count); } void bigint_init_bigfloat(BigInt *dest, const BigFloat *op) { @@ -227,7 +227,7 @@ void bigint_init_bigfloat(BigInt *dest, const BigFloat *op) { f128M_rem(&abs_val, &max_u64, &remainder); dest->digit_count = 2; - dest->data.digits = allocate_nonzero<uint64_t>(dest->digit_count); + dest->data.digits = heap::c_allocator.allocate_nonzero<uint64_t>(dest->digit_count); dest->data.digits[0] = f128M_to_ui64(&remainder, softfloat_round_minMag, false); dest->data.digits[1] = f128M_to_ui64(&amt, softfloat_round_minMag, false); bigint_normalize(dest); @@ -345,7 +345,7 @@ void bigint_read_twos_complement(BigInt *dest, const uint8_t *buf, size_t bit_co if (dest->digit_count == 1) { digits = &dest->data.digit; } else { - digits = allocate_nonzero<uint64_t>(dest->digit_count); + digits = heap::c_allocator.allocate_nonzero<uint64_t>(dest->digit_count); dest->data.digits = digits; } @@ -464,7 +464,7 @@ void bigint_add(BigInt *dest, const BigInt *op1, const BigInt *op2) { } size_t i = 1; uint64_t first_digit = dest->data.digit; - dest->data.digits = allocate_nonzero<uint64_t>(max(op1->digit_count, op2->digit_count) + 1); + dest->data.digits = heap::c_allocator.allocate_nonzero<uint64_t>(max(op1->digit_count, op2->digit_count) + 1); dest->data.digits[0] = first_digit; for (;;) { @@ -532,7 +532,7 @@ void bigint_add(BigInt *dest, const BigInt *op1, const BigInt *op2) { return; } uint64_t first_digit = dest->data.digit; - dest->data.digits = allocate_nonzero<uint64_t>(bigger_op->digit_count); + dest->data.digits = heap::c_allocator.allocate_nonzero<uint64_t>(bigger_op->digit_count); dest->data.digits[0] = first_digit; size_t i = 1; @@ -1032,7 +1032,7 @@ static void bigint_unsigned_division(const BigInt *op1, const BigInt *op2, BigIn if (lhsWords == 1) { Quotient->data.digit = Make_64(Q[1], Q[0]); } else { - Quotient->data.digits = allocate<uint64_t>(lhsWords); + Quotient->data.digits = heap::c_allocator.allocate<uint64_t>(lhsWords); for (size_t i = 0; i < lhsWords; i += 1) { Quotient->data.digits[i] = Make_64(Q[i*2+1], Q[i*2]); } @@ -1046,7 +1046,7 @@ static void bigint_unsigned_division(const BigInt *op1, const BigInt *op2, BigIn if (rhsWords == 1) { Remainder->data.digit = Make_64(R[1], R[0]); } else { - Remainder->data.digits = allocate<uint64_t>(rhsWords); + Remainder->data.digits = heap::c_allocator.allocate<uint64_t>(rhsWords); for (size_t i = 0; i < rhsWords; i += 1) { Remainder->data.digits[i] = Make_64(R[i*2+1], R[i*2]); } @@ -1218,7 +1218,7 @@ void bigint_or(BigInt *dest, const BigInt *op1, const BigInt *op2) { return; } dest->digit_count = max(op1->digit_count, op2->digit_count); - dest->data.digits = allocate_nonzero<uint64_t>(dest->digit_count); + dest->data.digits = heap::c_allocator.allocate_nonzero<uint64_t>(dest->digit_count); for (size_t i = 0; i < dest->digit_count; i += 1) { uint64_t digit = 0; if (i < op1->digit_count) { @@ -1262,7 +1262,7 @@ void bigint_and(BigInt *dest, const BigInt *op1, const BigInt *op2) { } dest->digit_count = max(op1->digit_count, op2->digit_count); - dest->data.digits = allocate_nonzero<uint64_t>(dest->digit_count); + dest->data.digits = heap::c_allocator.allocate_nonzero<uint64_t>(dest->digit_count); size_t i = 0; for (; i < op1->digit_count && i < op2->digit_count; i += 1) { @@ -1308,7 +1308,7 @@ void bigint_xor(BigInt *dest, const BigInt *op1, const BigInt *op2) { return; } dest->digit_count = max(op1->digit_count, op2->digit_count); - dest->data.digits = allocate_nonzero<uint64_t>(dest->digit_count); + dest->data.digits = heap::c_allocator.allocate_nonzero<uint64_t>(dest->digit_count); size_t i = 0; for (; i < op1->digit_count && i < op2->digit_count; i += 1) { dest->data.digits[i] = op1_digits[i] ^ op2_digits[i]; @@ -1358,7 +1358,7 @@ void bigint_shl(BigInt *dest, const BigInt *op1, const BigInt *op2) { uint64_t digit_shift_count = shift_amt / 64; uint64_t leftover_shift_count = shift_amt % 64; - dest->data.digits = allocate<uint64_t>(op1->digit_count + digit_shift_count + 1); + dest->data.digits = heap::c_allocator.allocate<uint64_t>(op1->digit_count + digit_shift_count + 1); dest->digit_count = digit_shift_count; uint64_t carry = 0; for (size_t i = 0; i < op1->digit_count; i += 1) { @@ -1421,7 +1421,7 @@ void bigint_shr(BigInt *dest, const BigInt *op1, const BigInt *op2) { if (dest->digit_count == 1) { digits = &dest->data.digit; } else { - digits = allocate<uint64_t>(dest->digit_count); + digits = heap::c_allocator.allocate<uint64_t>(dest->digit_count); dest->data.digits = digits; } @@ -1492,7 +1492,7 @@ void bigint_not(BigInt *dest, const BigInt *op, size_t bit_count, bool is_signed } dest->digit_count = (bit_count + 63) / 64; assert(dest->digit_count >= op->digit_count); - dest->data.digits = allocate_nonzero<uint64_t>(dest->digit_count); + dest->data.digits = heap::c_allocator.allocate_nonzero<uint64_t>(dest->digit_count); size_t i = 0; for (; i < op->digit_count; i += 1) { dest->data.digits[i] = ~op_digits[i]; |
