Gan_Vector vx, vy; /* declare vectors x & y */ gan_vec_form ( &vx, 0 ); /* create vector x */ gan_vec_form ( &vy, 0 ); /* create vector y */ gan_vec_fill_va ( &vx, 5, 11.0, 9.0, 7.0, 5.0, 3.0 ); /* reallocate & initialise x */ gan_vec_copy_q ( &vx, &vy ); /* set y = x, reallocating y */The last two lines reallocate first and then , because both were created with zero size. Note that may have previously been filled with other values, which are now lost.
There is also a version that creates a copy of a vector from scratch:
Gan_Vector *pvy; /* declare vector y */ pvy = gan_vec_copy_s ( &vx ); /* create y and set y = x */
Error detection: The vector copy routines return NULL and invoke the Gandalf error handler upon failure.