On Sunday, December 17, 2000, Jacques A. Vidrine wrote:
> I don't blame authors of storage allocation code if they do not write
> free like this:
> 
>     void
>     free(void *p)
>     {
>             if (p == NULL)
>                     return;
>         .
>         .
>         .
> 
> 
> It would be silly to optimize for freeing NULL pointers.

   You mean as seen in:

     static void
     ifree(void *ptr)
     { 
         struct pginfo *info;
         int index;
         
         /* This is legal */
         if (!ptr)
             return;
         .
         .
         .
         

   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.

-- 
+-------------------+----------------------------------------+
| Chris Costello    | All the simple programs have been      |
| [EMAIL PROTECTED] | written, and all the good names taken. |
+-------------------+----------------------------------------+


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to