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


Since free (NULL) is thoroughly well-specified as a no-op, it never
qualifies as a "cleanup" to add code to avoid it.  If anything, it's an
optimization.  Like all claims of optimization, it needs exploration of
the trade-offs involved and justification for the change.

It was past policy never to add tests before free calls.  The rationale
for that is that free (NULL) is cheap enough as a no-op and the cases
where it would actually be called are not in hot paths.  If they're not
hot paths, then there is no justification for an optimization change.
In fact, adding any instructions at all is should always be presumed to
be a pessimization due to general I-cache pressure.  So adding a test
must be justified on a specific performance-analysis basis as an
optimization, and weighed against the maintenance burden of making the
source code larger and more complex.


Thanks,
Roland


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