[PATCH] Change unix_convert to use struct smb_filename
Tim Prouty
tprouty at samba.org
Thu Apr 30 19:02:32 GMT 2009
On Apr 30, 2009, at 3:04 AM, Volker Lendecke wrote:
> On Tue, Apr 28, 2009 at 02:30:11PM -0700, Tim Prouty wrote:
>> NTSTATUS unix_convert(TALLOC_CTX *ctx,
>> connection_struct *conn,
>> const char *orig_path,
>> struct smb_filename *smb_fname,
>> uint32_t ucf_flags)
>
> Just a quick stylistic question: Why not allocate the
> smb_filename struct in unix_convert and have the substrings
> as talloc children off that? In case this turns out to be a
> malloc performance hit, we can always do the appropriate
> talloc_pool trick inside unix_convert.
Thanks for the feedback!
I was considering that option, but since we already had a talloc_ctx
being passed around, it seemed simpler to just have the smb_filename
struct sit on the stack. I guess one possible advantage of tallocing
an smb_filename struct is that the talloc_ctx arg could be eliminated
from unix_convert, further simplifying the API.
Another advantage is that the memory would be more cleanly tracked,
and could be freed earlier as soon as it is no longer being used. Are
there other advantages as well?
On a related note, in a future patch it would make sense to store the
smb_filename struct in the file_struct as well. To add this ability
I'll probably also add some utility functions that alloc/init/copy/etc
smb_filename structs. These utility structs could be used here as well.
I'm not familiar with the talloc_pool trick. Are there examples of
the trick in use elsewhere?
-Tim
More information about the samba-technical
mailing list