Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › math › big › int › Mutable › mul Public Function mul Doc Source Public Function std.math.big.int.Mutable.mul
pub fn mul (rma : *Mutable , a : Const , b : Const , limbs_buffer : []Limb , allocator : ?Allocator ) void Params File math/big/int.zig: 794
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812 pub fn mul (rma : *Mutable , a : Const , b : Const , limbs_buffer : []Limb , allocator : ?Allocator ) void {
var buf_index : usize = 0 ;
const a_copy = if (rma .limbs .ptr == a .limbs .ptr ) blk : {
const start = buf_index ;
@memcpy (limbs_buffer [buf_index ..][0 ..a .limbs .len ], a .limbs );
buf_index += a .limbs .len ;
break :blk a .toMutable (limbs_buffer [start ..buf_index ]).toConst ();
} else a ;
const b_copy = if (rma .limbs .ptr == b .limbs .ptr ) blk : {
const start = buf_index ;
@memcpy (limbs_buffer [buf_index ..][0 ..b .limbs .len ], b .limbs );
buf_index += b .limbs .len ;
break :blk b .toMutable (limbs_buffer [start ..buf_index ]).toConst ();
} else b ;
return rma .mulNoAlias (a_copy , b_copy , allocator );
}
rma = a * b
rmamay alias withaorb.aandbmay alias with each other.Asserts the result fits in
rma. An upper bound on the number of limbs needed by rma is given bya.limbs.len + b.limbs.len.limbs_bufferis used for temporary storage. The amount required is given bycalcMulLimbsBufferLen.