This is the patch for finalize backen of tevent

Jeremy Allison jra at samba.org
Fri Jan 11 16:32:47 MST 2013


On Mon, Dec 31, 2012 at 02:52:40PM +0800, Galen(liugang) wrote:
> As tevent_backend_init allocate some memory and there isn't other place to
> free it, so add a talloc_set_destructor on it.
> 
> --- tevent-0.9.17.orig/tevent.c    2012-08-17 22:39:01.000000000 +0800
> +++ tevent-0.9.17/tevent.c    2012-12-31 14:45:11.539407205 +0800
> @@ -122,6 +122,25 @@
>  }
> 
>  /*
> +  finalize backends
> +*/
> +static int tevent_backend_finalize(TALLOC_CTX *mem_ctx)
> +{
> +    struct tevent_ops_list *e, *en;
> +
> +    for (e = tevent_backends; e; e = en) {
> +        en = e->next;
> +        talloc_free(e);
> +    }
> +
> +    if (tevent_default_backend) {
> +        TALLOC_FREE(tevent_default_backend);
> +    }
> +
> +    return 0;
> +}
> +
> +/*
>    list available backends
>  */
>  const char **tevent_backend_list(TALLOC_CTX *mem_ctx)
> @@ -246,6 +265,7 @@
>      struct tevent_ops_list *e;
> 
>      tevent_backend_init();
> +    talloc_set_destructor(mem_ctx, tevent_backend_finalize);
> 
>      if (name == NULL) {
>          name = tevent_default_backend;

Ok I've had time to evaluate it and I'm afraid this is not
the correct fix.

You can't add the destructor to the memory context passed
into tevent_backend_list(), as this is only used to store
the text values of the backends available - it's not any
part of the tevent backend subsystems.

Jeremy.


More information about the samba-technical mailing list