[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] date: free allocated memory to fix Valgrind warning
From: |
Bernhard Voelker |
Subject: |
Re: [PATCH] date: free allocated memory to fix Valgrind warning |
Date: |
Tue, 16 Feb 2016 17:57:21 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 02/16/2016 05:00 PM, Eric Blake wrote:
> On 02/16/2016 06:42 AM, Daniel Lockyer wrote:
>> --- a/src/date.c
>> +++ b/src/date.c
>> @@ -548,6 +548,8 @@ main (int argc, char **argv)
>> ok &= show_date (format, when, tz);
>> }
>>
>> + free(tz);
>> +
>> return ok ? EXIT_SUCCESS : EXIT_FAILURE;
>> }
>
> Memory is going to be freed anyway by virtue of exiting; leaving
> something allocated is actually faster than freeing it. We typically
> mark code like this addition inside IF_LINT() so that it is only
> compiled to shut up valgrind, but intentionally omitted when we don't
> care about the leak.
Right, so I'll push the attached in Daniel's name soon.
Please note that I changed 'free' to 'tzfree' for correctness.
Have a nice day,
Berny
0001-date-free-timezone-variable-to-avoid-valgrind-warnin.patch
Description: Text Data