[PATCH] Use talloc_autofree_context() to allocate global memory

Kamen Mazdrashki kamenim at samba.org
Fri Sep 12 18:27:24 MDT 2014


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-util-debug-Use-talloc_autofree_context-instead-of-NU.patch
Type: text/x-patch
Size: 1414 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20140913/0f7e934c/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-util-debug-debug_list_class_names_and_levels-accept-.patch
Type: text/x-patch
Size: 3251 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20140913/0f7e934c/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-ldb_modules-use-talloc-autofree-context-to-allocate-.patch
Type: text/x-patch
Size: 1511 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20140913/0f7e934c/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-tevent-Allocate-tevent_ops_list-structures-in-autofr.patch
Type: text/x-patch
Size: 871 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20140913/0f7e934c/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-loadparm-Allocate-service-copymap-in-service-memory-.patch
Type: text/x-patch
Size: 1371 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20140913/0f7e934c/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-loadparm-init_copymap-Add-braces-around-if-for-block.patch
Type: text/x-patch
Size: 1038 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20140913/0f7e934c/attachment-0005.bin>


More information about the samba-technical mailing list