[PATCH] Add stackframes to public libsmbclient functions

tridge at samba.org tridge at samba.org
Wed Nov 28 04:37:12 GMT 2007


I know I'm coming into this debate a little late, but perhaps this

Change from this:

  	TALLOC_CTX *ctx = talloc_init("bla");
  	DEBUG(10, ("sid: %s\n", sid_string_talloc(ctx, sid)));

to this:

  DEBUG(10,("sid: %s\n", sid_string_talloc(debug_ctx(), sid)));

then put this in lib/debug.c:

 static void *tmp_debug_ctx;

 void *debug_ctx(void)
	if (tmp_debug_ctx == NULL) {
		tmp_debug_ctx = talloc_named_const(NULL, 0, "debug_ctx");
	return tmp_debug_ctx;

then in Debug1() add this at the end of the function:

  tmp_debug_ctx = NULL;

This only solves things for DEBUG() calls, but perhaps that is the
main source of pain?

The nice part of this idea is that:

 - due to the way the DEBUG() macro works, debug_ctx only gets created
   if we are indeed going to be writing something to the logs

 - it gets freed up immediately it is no longer needed. 

It still leaves us with a static, but its associated with only the
debug code.

Cheers, Tridge

More information about the samba-technical mailing list