svn commit: samba r11961 - in trunk/source: . lib utils

Jeremy Allison jra at
Wed Nov 30 00:20:55 GMT 2005

On Wed, Nov 30, 2005 at 11:14:39AM +1100, tridge at wrote:
> Jeremy,
>  > re-add the talloc_describe_all() function.
> It looks like this is a copy of the talloc_report_full() function, but
> with a different output routine. Perhaps we are better off creating a
> a varient of talloc_report_*() that takes a function pointer?
> This function pointer could either be a fprintf() style of function,
> but with a void* private pointer for the 'file', or we could instead
> make it a function that takes the details of a specific allocation as
> arguments, and allows the caller to format it as they wish.
> I think the latter is probably more useful, particularly as it allows
> for things like GUIs, web interfaces etc, without them having to try
> and parse the human-readable output. 
> So, how about this for a interface:
>   void talloc_report_function(void *ptr, talloc_report_fn_t fn, void *private);
>   typedef void (*talloc_report_fn_t)(void *, void *, size_t, const char *, int);
> a simple report function would be:
>   void my_report(void *private, void *ptr, size_t size, const char *name, int is_reference)
>   {
> 	if (is_reference) {
> 		printf("reference to %p\n", ptr);
> 	} else {
> 		printf("ptr %p of size %u has name '%s'\n", ptr, size, name);
> 	}
>   }
> talloc_report_function() would only traverse the direct children of
> the pointer, leaving it up to the callback function to recurse if it
> wants to.

Yes, it's a copy of talloc_report_full, but uses a Samba3 specific output
function I don't think is available in Samba4. I originally tried to use
talloc_vasprintf_append() to build the output but kept getting valgrind
errors about reusing free'd memory. I think it was to do with trying to
print the string you're constructing as talloc_vasprintf_append() calls
talloc_set_name_const with the constructed string.... It ended up being
easier to use a malloc'ed area instead but wasn't as elegent.

I thought about making the void * a file but didn't want to mess with
existing working talloc code. That's a cleaner solution and if I had
more time I'd have done it :-). If you want to fix it up I'd appreciate
it :-).



More information about the samba-technical mailing list