IntTryClone
Description
Create a deep copy of an integer.
Parameters
| Name | Direction | Description |
|---|---|---|
out |
in,out | Destination Int that receives the clone. Must already be a valid initialised Int; its existing storage is deinitialised before the copy is installed. |
value |
in | Source Int to clone. Not modified. |
Success
Returns true. *out holds an independent deep copy of value’s bit-vector, normalised, and bound to value’s allocator.
Failure
Returns false on allocation failure while copying the bit-vector. *out is left as a freshly initialised empty Int bound to value’s allocator.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.c:456:
}
bool IntTryClone(Int *out, const Int *value) {
return int_try_clone_value(out, value);
}- In
Int.c:1720:
Int zero_rem = IntInit(IntAllocator(remainder));
if (!IntTryClone(&exact_root, value)) {
IntDeinit(&exact_root);
IntDeinit(&zero_rem);- In
Int.c:1793:
IntDeinit(&best);
if (!IntTryClone(&best, &mid)) {
IntDeinit(&mid_pow);
IntDeinit(&mid);- In
Int.c:2240:
Int exp = IntInit(IntAllocator(exponent));
if (!int_try_from_u64(&acc, 1, IntAllocator(result)) || !IntTryClone(&exp, exponent) ||
!int_mod(&acc, &acc, modulus) || !int_mod(&base_mod, base, modulus)) {
IntDeinit(&acc);- In
Int.c:2316:
bool ok = false;
if (!IntTryClone(&r, modulus) || !int_mod(&reduced, value, modulus)) {
IntDeinit(&reduced);
IntDeinit(&r);- In
Int.c:2325:
return false;
}
if (!IntTryClone(&new_r, &reduced)) {
IntDeinit(&reduced);
IntDeinit(&r);- In
Int.c:2480:
Int root = IntInit(IntAllocator(result));
if (!IntTryClone(&exponent, modulus) || !int_add_u64(&exponent, &exponent, 1) || !IntShiftRight(&exponent, 2) ||
!int_pow_mod(&root, &a, &exponent, modulus)) {
IntDeinit(&exponent);- In
Int.c:2503:
u64 m = 0;
if (!IntTryClone(&q, modulus) || !int_try_from_u64(&z, 2, IntAllocator(modulus)) || !int_sub_u64(&q, &q, 1)) {
IntDeinit(&q);
IntDeinit(&z);- In
Int.c:2568:
}
if (!IntTryClone(&exponent, &q) || !int_add_u64(&exponent, &exponent, 1) || !IntShiftRight(&exponent, 1) ||
!int_pow_mod(&r, &a, &exponent, modulus)) {
IntDeinit(&q);- In
Int.c:2584:
u64 i = 0;
if (!IntTryClone(&t_power, &t)) {
IntDeinit(&t_power);
IntDeinit(&q);- In
Int.c:2629:
Int next = IntInit(IntAllocator(result));
if (!IntTryClone(&b, &c)) {
IntDeinit(&b);
IntDeinit(&b_sq);- In
Int.c:2774:
bool probable = true;
if (!IntTryClone(&d, value) || !int_sub_u64(&d, &d, 1)) {
IntDeinit(&d);
IntDeinit(&n_minus_one);- In
Int.c:2779:
return false;
}
if (!IntTryClone(&n_minus_one, &d)) {
IntDeinit(&d);
IntDeinit(&n_minus_one);- In
Int.c:2885:
Int candidate = IntInit(IntAllocator(result));
if (!IntTryClone(&candidate, value)) {
IntDeinit(&candidate);
return false;- In
Float.c:302:
out->negative = value->negative;
out->exponent = value->exponent;
if (!IntTryClone(&out->significand, &value->significand)) {
FloatDeinit(out);
*out = FloatInit(FloatAllocator(value));- In
Float.c:354:
ValidateInt(value);
*out = FloatInit(IntAllocator(value));
if (!IntTryClone(&out->significand, value)) {
FloatDeinit(out);
*out = FloatInit(IntAllocator(value));- In
Float.c:425:
Int factor = IntInit(FloatAllocator(value));
if (!IntTryClone(&temp, &value->significand) ||
!float_pow10(&factor, (u64)value->exponent, FloatAllocator(value)) || !int_mul(&temp, &temp, &factor)) {
IntDeinit(&factor);
Last updated on