home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!lynx.COM!bitbug
- From: bitbug@lynx.COM (James Buster)
- Newsgroups: gnu.utils.bug
- Subject: memory leak fixes to make 3.63
- Date: 26 Jan 1993 22:22:33 -0500
- Organization: GNUs Not Usenet
- Lines: 63
- Sender: daemon@cis.ohio-state.edu
- Approved: bug-gnu-utils@prep.ai.mit.edu
- Distribution: gnu
- Message-ID: <m0nGxGl-0000SEC@liberator.lynx.com>
-
- Here is a unified diff to fix memory leaks in commands.c:
-
- --- commands.c.orig Tue Jan 26 13:46:57 1993
- +++ commands.c Tue Jan 26 13:48:12 1993
- @@ -36,7 +36,7 @@
- register struct file *file;
- {
- register char *p;
- - char *at, *percent, *star, *less;
- + char *at, *percent, *star, *less, *save;
-
- #define DEFINE_VARIABLE(name, len, value) \
- (void) define_variable_for_file (name, len, value, o_automatic, 0, file)
- @@ -56,7 +56,7 @@
- #endif /* NO_ARCHIVES. */
- {
- at = savestring (file->name, strlen (file->name));
- - percent = "";
- + percent = savestring ("", 0);
- }
-
- DEFINE_VARIABLE ("@", 1, at);
- @@ -64,8 +64,8 @@
-
- #define LASTSLASH(s) rindex ((s), '/')
- #define FILEONLY(s) (p != 0 ? p + 1 : (s))
- -#define DIRONLY(s) (p == 0 ? "./" : p == (s) ? "/" \
- - : savestring ((s), (p - (s)) + 1))
- +#define DIRONLY(s) (p == 0 ? savestring ("./", 2) : p == (s) ? \
- + savestring ("/", 1) : savestring ((s), (p - (s)) + 1))
-
- /* $* is the stem from an implicit or static pattern rule. */
- if (file->stem == 0)
- @@ -118,17 +118,24 @@
-
- /* Set up the D and F versions. */
- p = LASTSLASH (at);
- - DEFINE_VARIABLE ("@D", 2, DIRONLY (at));
- + DEFINE_VARIABLE ("@D", 2, save = DIRONLY (at));
- + free (save);
- DEFINE_VARIABLE ("@F", 2, FILEONLY (at));
- p = LASTSLASH (star);
- - DEFINE_VARIABLE ("*D", 2, DIRONLY (star));
- + DEFINE_VARIABLE ("*D", 2, save = DIRONLY (star));
- + free (save);
- DEFINE_VARIABLE ("*F", 2, FILEONLY (star));
- p = LASTSLASH (less);
- - DEFINE_VARIABLE ("<D", 2, DIRONLY (less));
- + DEFINE_VARIABLE ("<D", 2, save = DIRONLY (less));
- + free (save);
- DEFINE_VARIABLE ("<F", 2, FILEONLY (less));
- p = LASTSLASH (percent);
- - DEFINE_VARIABLE ("%D", 2, DIRONLY (percent));
- + DEFINE_VARIABLE ("%D", 2, save = DIRONLY (percent));
- + free (save);
- DEFINE_VARIABLE ("%F", 2, FILEONLY (percent));
- +
- + free (at);
- + free (percent);
-
- /* Make sure that no dependencies are repeated. This does not
- really matter for the purpose of updating targets, but it
-
-