The pointer argument must be passed by reference, because it is replaced:
procedure Lengthen(var n: number)
    old := n
    L := len(old)
    new(result, 2*L)
    for i := 0 to L-1 do
        result[i] := old[i]
    for i := L to 2*L-1 do
        result[i] := 0
    n := result
The low-order coefficients are preserved and the newly allocated high-order coefficients are zero, so the digit-array integer representation has the same value. The allocation remains nonempty because . Neither allocation nor an uninitialized high-order cell may be assumed to contain zero. Any other reference to the old array still denotes that old array; the code does not free storage through an alias.

Articles by others on the same topic (0)

There are currently no matching articles.