[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] Re: free
From: |
John D Lamb |
Subject: |
Re: [Help-gsl] Re: free |
Date: |
Mon, 12 Jun 2006 21:32:55 +0100 |
User-agent: |
Thunderbird 1.5 (X11/20060317) |
Brian Gough wrote:
> Jochen Küpper writes:
> > > I checked the source code for gsl_matrix_free and it will fail if passed
> > > a null pointer.
> >
> > Shouldn't the GSL free-routines be changed like the following patch?
>
> My thinking on that was that for most people calling the free()
> functions on a null pointer is usually an error rather than by design,
> so it's helpful to get a segmentation fault.
>
> In general, I've never been convinced that free'ing a null pointer is
> particularly useful as opposed to just doing "if (p) free(p)" in the
> application.
A check in the _free codes would also add a small overhead. I think
there's an arguable case for a delete() function that checks for a null
pointer. But GSL is a C library, not a C++ library and there's no new()
function to go along with it, which ought to can throw a bad_alloc
exception, not available in C.
In any case there's no difficulty to write your own inline new() and
delete() functions as needed.
--
JDL
- [Help-gsl] Help with GSL Matrices, adarsh, 2006/06/10
- Message not available
- Re: [Help-gsl] Help with GSL Matrices, John D Lamb, 2006/06/11
- Re: [Help-gsl] Help with GSL Matrices, Jochen Küpper, 2006/06/11
- Re: [Help-gsl] Help with GSL Matrices, John D Lamb, 2006/06/11
- free (was: [Help-gsl] Help with GSL Matrices), Jochen Küpper, 2006/06/11
- [Help-gsl] Re: free, John D Lamb, 2006/06/11
- [Help-gsl] Re: free, Jochen Küpper, 2006/06/11
- [Help-gsl] Re: free, Brian Gough, 2006/06/12
- Re: [Help-gsl] Re: free,
John D Lamb <=
- Re: [Help-gsl] Re: free, Jochen Küpper, 2006/06/12
- Re: [Help-gsl] Re: free, Brian Gough, 2006/06/14
Re: [Help-gsl] Help with GSL Matrices, adarsh, 2006/06/11