On Sun, Dec 17, 2000 at 03:36:56PM -0600, Chris Costello wrote:
> On Sunday, December 17, 2000, Jacques A. Vidrine wrote:
> > It would be silly to optimize for freeing NULL pointers.
>
> You mean as seen in:
[snip ifree(), which checks for a NULL pointer, first thing]
> called by free():
>
> void
> free(void *ptr)
> {
> THREAD_LOCK();
> malloc_func = " in free():";
> if (malloc_active++) {
> wrtwarning("recursive call.\n");
> malloc_active--;
> return;
> } else {
> ifree(ptr);
> .
> .
> .
>
> That's how it's worked since before FreeBSD came into being.
> It wasn't implemented the same, but it behaved the same.
I may have missed your point ... or maybe you are just agreeing with
what I wrote. For this particular implementation of free, you get the
following for `free(foo)' when foo == NULL:
function call and stack overhead for free()
lock something if we are threaded
pointer assignment
increment
compare and branch
function call and stack overhead for ifree()
compare and branch
unwind ifree()
More stuff if HAVE_UTRACE
decrement
unlock something
unwind free()
Compare to `if (foo) free(foo);'
compare and branch
i.e. FreeBSD's free() is not optimized for freeing NULL pointers. Not
that I think it should be -- as I said, that would be silly.
--
Jacques Vidrine / [EMAIL PROTECTED] / [EMAIL PROTECTED] / [EMAIL PROTECTED]
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message