[PATCH] Add stackframes to public libsmbclient functions

Gerald (Jerry) Carter jerry at samba.org
Mon Nov 19 15:48:39 GMT 2007

Hash: SHA1

Derrell Lipman wrote:
> On Nov 19, 2007 10:37 AM, Volker Lendecke <Volker.Lendecke at sernet.de> wrote:
>> On Mon, Nov 19, 2007 at 10:31:16AM -0500, Derrell Lipman wrote:
>>> lower-layer functions.  Without some strong reason to the contrary, I
>>> prefer the black-box concept with inputs and outputs well defined by
>>> parameters and return value.
>> Can you please then provide some hints how to solve the
>> DEBUG(10, ("sid: %s\n", sid_string_static(sid)));
>> problem? sid_string_static using a static variable is much
>> worse than passing a magic talloc ctx in my opinion. Or
>> should we go back to using those?
> I don't have any problem with providing a talloc context; I just don't
> like it being "magic".  If a context is needed, it should be passed as
> a parameter, I think.  Am I missing something, or do you just not like
> the concept of passing it as a parameter?

Ahh... Now I understand what your objecting to.

In some ways I would agree with you.  Consider this an interem step
to allow removing static buffers without having to change the
function signature which is an acceptable tradeoff.

The main thing is functions that return pointers such as the one
Volker points out.  There are three options I see:

  (a) static buffers (bad)
  (b) malloc'd memory (troublesome)
  (c) talloc memory (clean)

However, since talloc'd memory requires a parent context (or
else it suffers from the same problem as (b)) you either
have to pass a CTX in which itself becomes very cumbersome
and is more prone to allow the programmer to use the wrong

The talloc_stackframe() mechanisms allows all the advantages of
malloc'd memory without the leaking problems.

cheers, jerry

Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


More information about the samba-technical mailing list