On 02/16/2016 06:42 AM, Daniel Lockyer wrote: > When running Valgrind to monitor ./src/date, it reports the variable `tz` > isn't freed when the program exits. I simply added a `free(tz)` call > to clean this up. > --- > src/date.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/src/date.c b/src/date.c > index 3670553..23eef87 100644 > --- 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. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
