Re: [patch] tsearch.3: dispose properly of allocated resources in example code

André Goddard Rosa
2008-09-23T13:23:51Z

On Tue, Sep 23, 2008 at 3:28 AM, Michael Kerrisk
<mtk.manpages-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:
> André,
>
> On Sun, Sep 21, 2008 at 8:10 AM, André Goddard Rosa
> <andre.goddard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> As there are many users who base their own code on these examples, we
>> should avoid leaking memory when using functions of tsearch() family.
>> In the provided example, tsearch() leaks memory whenever it tries to
>> insert a number which was already inserted before.
>
> Thanks. My first patch applied via 'git am'!
>
> I applied this patch for man-pages-3.10. (I added
> #define _GNU_SOURCE
> since that's required to expose the tdestroy() declaration.)
>

Hi, Michael!

Very nice, thank you! Good to know that you're using git.

I appreciate your work in the man pages, they were improved a lot
since you've started working on them. Also, I appreciate your concerns
regarding paccept().

Notice that I sent two different patches in a sequence (sorry for that).

This is the first one:

> + else if (!((*(int **) val) == ptr))

and this is the second one:

+ else if ((*(int **) val) != ptr)

They work the same, but second is cleaner and simpler ;-)

Kind regards,
--
[]s,
André Goddard