Dear GSL Administrator,

I refer to the example code in the GSL reference manual online,
under the section "Nonlinear Least-Squares Fitting" at
http://www.gnu.org/software/gsl/manual/gsl-ref_37.html#SEC476

I tried to replace the 11th line of code in the main method
by replacing the double array with initializer list
with a double pointer to an array initialized using "new", and using 
"delete [ ]" afterwards.

-------------------------------------------------------------------

int
main (void)
{
        ...
        ...
        ...
 

        // Original approach:
        // double x_init[3] = { 1.0, 0.0, 0.0 };

        // My approach: try allocating on heap instead 
        // --> runs fine, but fails in purify (memory leak)
        double * x_init = new double[ 3 ]; 
        x_init[0] = 1.0; 
        x_init[1] = 0.0; 
        x_init[2] = 0.0; 
 
        gsl_vector_view x = gsl_vector_view_array (x_init, p);

        ...
        ...
        ...

        delete [] x_init; 

        return 0;
}

-------------------------------------------------------------------

The result was that the example still ran fine normally,
but in "Purify", memory leaks are detected when in the original example,
no memory leaks were found.

Please advise.

Thank you.


Sincerely,

Wylie Chan

Fixed Income Research
Freddie Mac
1551 Park Run Dr.,
McLean, VA 22102
_______________________________________________
Bug-gsl mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-gsl

Reply via email to