This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Cleanup: don't call free(NULL) unnecessarily


On Wed, Mar 06, 2013 at 09:27:35AM +0100, Thomas Schwinge wrote:
> > --- a/stdio-common/vfprintf.c
> > +++ b/stdio-common/vfprintf.c
> > @@ -1691,7 +1691,8 @@ do_positional:
> >      /* Just a counter.  */
> >      size_t cnt;
> >  
> > -    free (workstart);
> > +    if (__builtin_expect (workstart != NULL, 0))
> > +      free (workstart);
> 
> Given that in the past, for example, in commits
> 62605cbfcb3d2f118c9f64ce049220b82928e6d4 and
> 72e6cdfa2cd95240439c72705ab28a2eebb7d04e (ChangeLog in commit
> 0726cdf7dbdccdf0f99d910d5e7799d902a1ec38) such checks have been removed,
> does this (and likewise for other cases) warrant a comment being added,
> or some other form of (user-accessible) documentation update what this
> change achieves?

I think there may also be a concern that gcc will eliminate the check
based on its knowledge of the semantics of free... Even if it's not
doing that now, it might in the future. This should not happen if
-ffreestanding is used, but as far as I know, glibc is not building
with that option presently, and from an optimization standpoint most
things in libc will benefit from not using -ffreestanding.

Rich


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]