[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] Re: free
From: |
Jochen Küpper |
Subject: |
Re: [Help-gsl] Re: free |
Date: |
Mon, 12 Jun 2006 23:23:23 +0200 |
John D Lamb <address@hidden> writes:
> Brian Gough wrote:
>> Jochen Küpper writes:
>>> 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.
> A check in the _free codes would also add a small overhead.
Two good arguments; I agree that the current code is what it should
be.
Maybe a comment could be added in the code:
,----
| Index: block/init_source.c
| ===================================================================
| RCS file: /cvs/gsl/gsl/block/init_source.c,v
| retrieving revision 1.7
| diff -u -r1.7 init_source.c
| --- block/init_source.c 26 Jun 2005 13:26:59 -0000 1.7
| +++ block/init_source.c 12 Jun 2006 21:20:39 -0000
| @@ -74,6 +74,11 @@
| void
| FUNCTION (gsl_block, free) (TYPE (gsl_block) * b)
| {
| + // no check for b == 0 performed:
| + // - For most people calling this function on a null pointer is
| + // usually an error, rather than by design, so it is helpful
| + // to get a segmentation fault.
| + // - The check imposes a small performance overhead.
| free (b->data);
| free (b);
| }
`----
This might be rephrased shorter/better by a native speaker... Thinking
of it, maybe it should even go into the documentation.
Greetings,
Jochen
--
Einigkeit und Recht und Freiheit http://www.Jochen-Kuepper.de
Liberté, Égalité, Fraternité GnuPG key: CC1B0B4D
(Part 3 you find in my messages before fall 2003.)
- [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, 2006/06/12
- Re: [Help-gsl] Re: free,
Jochen Küpper <=
- Re: [Help-gsl] Re: free, Brian Gough, 2006/06/14
Re: [Help-gsl] Help with GSL Matrices, adarsh, 2006/06/11