s4:dsdb - remove some calls of "samdb_msg_add_string" when we have talloc'ed strings

Matthias Dieter Wallnöfer mdw at samba.org
Sun Oct 24 14:43:56 MDT 2010


Andrew,

well, the idea would be to start going away from "samdb_msg_add_string" 
and use "ldb_msg_add_string" or "ldb_msg_add_steal_string" (from the LDB 
api). We need to reduce these redundant functions. Well here it's a bit 
different - since "samdb_msg_add_string" always "talloc_strdup"'s and 
"ldb_msg_add_string" doesn't.

Greets,
Matthias

Andrew Bartlett wrote:
> On Sun, 2010-10-24 at 22:04 +0200, Matthias Dieter Wallnöfer wrote:
>    
>> The branch, master has been updated
>>         via  7b3dbbd s4:dsdb - remove some calls of "samdb_msg_add_string" when we have talloc'ed strings
>>        from  177aad5 talloc: pytalloc should not depend on samba specific code
>>
>> http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
>>
>>
>> - Log -----------------------------------------------------------------
>> commit 7b3dbbde04d52f9faeeba507b82bc4242b1efddd
>> Author: Matthias Dieter Wallnöfer<mdw at samba.org>
>> Date:   Thu Oct 14 22:26:44 2010 +0200
>>
>>      s4:dsdb - remove some calls of "samdb_msg_add_string" when we have talloc'ed strings
>>
>>      They can be substituted by "ldb_msg_add_string" if the string was already
>>      talloc'ed.
>>      
> Matthias,
>
> Do you know that moving
>   - ret = samdb_msg_add_string(ldb, ac->msg, ac->msg,
> -                             "defaultObjectCategory",
> -                             ldb_dn_get_linearized(ac->dn));
> +  ret = ldb_msg_add_string(ac->msg, "defaultObjectCategory",
> +                           ldb_dn_alloc_linearized(ac, ac->dn));
>
> Doesn't really change anything?  In both cases you do a talloc_strdup(),
> it's just a matter of where.
>
> In the rpc_server case, I think what you want is
> 'ldb_msg_add_steal_string()'.  This will put the string in the right
> place in the talloc tree of the message.  (If you keep/repeat the
> ldb_dn_alloc...() related change, then ldb_msg_add_steal_string() would
> be appropriate here too).
>
> Of course, be careful when making these changes - to ensure that it's
> right to steal these particular strings.
>
> Andrew Bartlett
>
>    



More information about the samba-technical mailing list