[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] gnulib: close file handler before exiting
From: |
Bruno Haible |
Subject: |
Re: [PATCH] gnulib: close file handler before exiting |
Date: |
Mon, 29 Apr 2024 14:48:49 +0200 |
Hi,
> diff --git a/lib/gen-uni-tables.c b/lib/gen-uni-tables.c
> index 3ebcd83..94c687f 100644
> --- a/lib/gen-uni-tables.c
> +++ b/lib/gen-uni-tables.c
> @@ -242,6 +242,8 @@ fill_attributes (const char *unicodedata_filename)
> {
> fprintf (stderr, "missing end range in '%s':%d\n",
> unicodedata_filename, lineno);
> +
> + fclose (stream);
> exit (1);
> }
> if (!(field1[0] == '<'
Thanks for the patch. It would not be wrong to close the stream, here,
right before exit(), but
- It is unnecessary, since it happens during exit() anyway.
- The GNU Coding Standards [1] say about memory allocation:
"Memory analysis tools such as valgrind can be useful, but don’t
complicate a program merely to avoid their false alarms. For
example, if memory is used until just before a process exits,
don’t free it simply to silence such a tool."
and the same argument can be made for resource leaks (file
descriptor leaks).
Bruno
[1] https://www.gnu.org/prep/standards/html_node/Memory-Usage.html