Revision 755d5487f554cf585f3b988088dc20fad65d1bf6

Shkutkov Michael mish at rsu.ru
Thu Jul 12 04:11:14 EDT 2007


Richard Laager wrote:
>> And the caller of
>> purple_log_write() shouldn't have to deal with it.  Mostly I'm just wary about
>> adding an extra callback function everywhere to free the message.  What do
>> other people think?
>>     
>
> I think the callback should be optional. If NULL, no callback would be
> made. Then existing callers could call purple_log_write_nonblocking with
> NULL for each of the callback and data.
>
>   

Callback in purple_log_write_nonblocking is optional, so it's possible 
pass NULL argument.

> This leaves two questions:
>
> 1) Should purple_log_write_nonblocking g_strdup from and message, or
> should they be char *s that it takes ownership of? Michael, I think you
> should see what happens with those variables for most calls to
> purple_log_write(). If everyone is immediately freeing those, then we
> should have it take ownership instead. If some callers are not
> immediately freeing them, then we should have it g_strdup them.
>
> You may find that from is typically being re-used while message is not.
> If that's the case, we can leave from as a const char * and g_strdup it,
> but take ownership of message.
>   

I've look through the code once more, for all calls we free messages 
immediatly after call, so we can take
ownership,but there is case when purple_log_write is placed into loop so 
we must pass a copy of message
to purple_log_write. A piece of code for more defails:
      
   
        for (log = conv->logs; log != NULL; log = g_list_next(log))
            purple_log_write_nonblocking((PurpleLog *)log->data, flags, 
alias,
                            mtime, g_strdup(message), NULL, NULL);
   
If it's ok and not overkill, we definitly need take ownership of 
message, as for from variable, we
should leave as it is.

-- 
With best regards,
Shkutkov Michael




More information about the Devel mailing list