Jim Meyering wrote:
> Eric Blake <[EMAIL PROTECTED]> wrote:
>> According to Jim Meyering on 3/25/2008 3:47 PM:
>> | -      user_name = pwd ? pwd->pw_name : NULL;
>> | +      user_name = pwd ? xstrdup (pwd->pw_name) : NULL;
>>
>> Doesn't this leak memory?
> 
> Thanks for mentioning it, but I think of this as a pseudo leak,
> since that allocated storage is still reachable at exit:
> 
>     $ valgrind --leak-check=full --show-reachable=yes ./id -G
>     ...
>     ==18858== 9 bytes in 1 blocks are still reachable in loss record 1 of 4
>     ==18858==    at 0x4C20FAB: malloc (vg_replace_malloc.c:207)
>     ==18858==    by 0x403D49: xstrdup (in /f/w/cu/src/id)
>     ==18858==    by 0x40198E: main (id.c:214)
>     ...
> 
> IMHO, it's best not even to try to free such memory,
> unless the total amount can become large enough to interfere
> with regular operation.

It's easier to use the tools though without this "noise".
For my own programs I often change main to run in an
infinite loop (with suitable ulimit) to check leaks.

Pádraig.


_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to