all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] * lib-src/etags.c: Free variables.
@ 2022-12-09 15:03 lu4nx
  2022-12-09 15:30 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: lu4nx @ 2022-12-09 15:03 UTC (permalink / raw)
  To: emacs-devel; +Cc: lu4nx

---
 lib-src/etags.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib-src/etags.c b/lib-src/etags.c
index a06c236140..0822882d46 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -1339,6 +1339,8 @@ main (int argc, char **argv)
 			   "AND read file names from it");
 		  while (readline_internal (&filename_lb, stdin, "-", false) > 0)
 		    process_file_name (filename_lb.buffer, lang);
+
+                  free (filename_lb.buffer);
 		}
 	      else
 		process_file_name (this_file, lang);
@@ -1375,6 +1377,7 @@ main (int argc, char **argv)
 	  while (nincluded_files-- > 0)
 	    fprintf (tagf, "\f\n%s,include\n", *included_files++);
 
+          free (*included_files);
 	  if (fclose (tagf) == EOF)
 	    pfatal (tagfile);
 	}
@@ -1400,6 +1403,8 @@ main (int argc, char **argv)
       append_to_tagfile = true;
     }
 
+  free (argbuffer);
+
   tagf = fopen (tagfile, append_to_tagfile ? "ab" : "wb");
   if (tagf == NULL)
     pfatal (tagfile);
-- 
2.38.1




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] * lib-src/etags.c: Free variables.
  2022-12-09 15:03 [PATCH] * lib-src/etags.c: Free variables lu4nx
@ 2022-12-09 15:30 ` Eli Zaretskii
  2022-12-09 15:35   ` lux
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2022-12-09 15:30 UTC (permalink / raw)
  To: lu4nx; +Cc: emacs-devel

> From: lu4nx <lx@shellcodes.org>
> Cc: lu4nx <lx@shellcodes.org>
> Date: Fri,  9 Dec 2022 23:03:04 +0800
> 
> ---
>  lib-src/etags.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/lib-src/etags.c b/lib-src/etags.c
> index a06c236140..0822882d46 100644
> --- a/lib-src/etags.c
> +++ b/lib-src/etags.c
> @@ -1339,6 +1339,8 @@ main (int argc, char **argv)
>  			   "AND read file names from it");
>  		  while (readline_internal (&filename_lb, stdin, "-", false) > 0)
>  		    process_file_name (filename_lb.buffer, lang);
> +
> +                  free (filename_lb.buffer);
>  		}
>  	      else
>  		process_file_name (this_file, lang);
> @@ -1375,6 +1377,7 @@ main (int argc, char **argv)
>  	  while (nincluded_files-- > 0)
>  	    fprintf (tagf, "\f\n%s,include\n", *included_files++);
>  
> +          free (*included_files);
>  	  if (fclose (tagf) == EOF)
>  	    pfatal (tagfile);
>  	}
> @@ -1400,6 +1403,8 @@ main (int argc, char **argv)
>        append_to_tagfile = true;
>      }
>  
> +  free (argbuffer);
> +
>    tagf = fopen (tagfile, append_to_tagfile ? "ab" : "wb");
>    if (tagf == NULL)
>      pfatal (tagfile);

What is the rationale for these changes?  If a variable is not used
until the program exits, there's no need to free it.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] * lib-src/etags.c: Free variables.
  2022-12-09 15:30 ` Eli Zaretskii
@ 2022-12-09 15:35   ` lux
  0 siblings, 0 replies; 3+ messages in thread
From: lux @ 2022-12-09 15:35 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On Fri, 09 Dec 2022 17:30:42 +0200
Eli Zaretskii <eliz@gnu.org> wrote:

> > From: lu4nx <lx@shellcodes.org>
> > Cc: lu4nx <lx@shellcodes.org>
> > Date: Fri,  9 Dec 2022 23:03:04 +0800
> > 
> > ---
> >  lib-src/etags.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/lib-src/etags.c b/lib-src/etags.c
> > index a06c236140..0822882d46 100644
> > --- a/lib-src/etags.c
> > +++ b/lib-src/etags.c
> > @@ -1339,6 +1339,8 @@ main (int argc, char **argv)
> >  			   "AND read file names from it");
> >  		  while (readline_internal (&filename_lb, stdin,
> > "-", false) > 0) process_file_name (filename_lb.buffer, lang);
> > +
> > +                  free (filename_lb.buffer);
> >  		}
> >  	      else
> >  		process_file_name (this_file, lang);
> > @@ -1375,6 +1377,7 @@ main (int argc, char **argv)
> >  	  while (nincluded_files-- > 0)
> >  	    fprintf (tagf, "\f\n%s,include\n", *included_files++);
> >  
> > +          free (*included_files);
> >  	  if (fclose (tagf) == EOF)
> >  	    pfatal (tagfile);
> >  	}
> > @@ -1400,6 +1403,8 @@ main (int argc, char **argv)
> >        append_to_tagfile = true;
> >      }
> >  
> > +  free (argbuffer);
> > +
> >    tagf = fopen (tagfile, append_to_tagfile ? "ab" : "wb");
> >    if (tagf == NULL)
> >      pfatal (tagfile);  
> 
> What is the rationale for these changes?  If a variable is not used
> until the program exits, there's no need to free it.
> 

Ok, thanks, just added it by the way when reviewing the code.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-09 15:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-09 15:03 [PATCH] * lib-src/etags.c: Free variables lu4nx
2022-12-09 15:30 ` Eli Zaretskii
2022-12-09 15:35   ` lux

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.