[PATCH] Use talloc_autofree_context() to allocate global memory
Kamen Mazdrashki
kamenim at samba.org
Tue Sep 30 18:56:59 MDT 2014
Hi team,
I have rebased the patches on top of latest master.
*
http://git.samba.org/?p=kamenim/samba.git;a=shortlog;h=refs/heads/util-debug-use-autofree-context
* https://github.com/kamenim/samba/pull/1 - for github lovers published as
pull request
Any reviews (or reviewd-by) are appreciated :)
Cheers,
Kamen
On Sat, Sep 13, 2014 at 2:27 AM, Kamen Mazdrashki <kamenim at samba.org> wrote:
> Hi Metze,
>
> On Fri, Sep 12, 2014 at 12:28 PM, Stefan (metze) Metzmacher <
> metze at samba.org> wrote:
>
>> Hi Kamen,
>>
>> > --- a/lib/util/debug_s3.c
>> > +++ b/lib/util/debug_s3.c
>> > @@ -84,10 +84,19 @@ static void debuglevel_message(struct
>> messaging_context *msg_ctx,
>> > struct server_id src,
>> > DATA_BLOB *data)
>> > {
>> > - char *message = debug_list_class_names_and_levels();
>> > + char *message;
>> > + TALLOC_CTX *temp_ctx;
>> >
>> > + temp_ctx = talloc_new(NULL);
>> > + if (temp_ctx == NULL) {
>> > + DEBUG(0,("debuglevel_message - Unable to allocate local
>> mem context. Possibly OOM!\n"));
>> > + return;
>> > + }
>>
>> Wouldn't it be better to use talloc_stackframe() here?
>>
>> yes, it is better. Please take a look - PATCH 0002
> Also quick preview at:
> https://github.com/kamenim/samba/commit/cd1c919013c9f9885ef59c7c8a621c7061b7199d
>
> For a moment I thought it is stackframe implementation that gives yet
> another memory leak somewhere in master,
> but it turns out it is somewhere else (don't know yet, but at the moment
> those patches works great for me for 4.1.11)
>
>
>> > + message = debug_list_class_names_and_levels(temp_ctx);
>> > if (!message) {
>> > DEBUG(0,("debuglevel_message -
>> debug_list_class_names_and_levels returned NULL\n"));
>> > + TALLOC_FREE(temp_ctx);
>> > return;
>> > }
>>
>> metze
>>
>>
> Cheers,
> Kamen
>
More information about the samba-technical
mailing list