home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / gnu / utils / bug / 2493 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  2.4 KB

  1. 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
  2. From: bitbug@lynx.COM (James Buster)
  3. Newsgroups: gnu.utils.bug
  4. Subject: memory leak fixes to make 3.63
  5. Date: 26 Jan 1993 22:22:33 -0500
  6. Organization: GNUs Not Usenet
  7. Lines: 63
  8. Sender: daemon@cis.ohio-state.edu
  9. Approved: bug-gnu-utils@prep.ai.mit.edu
  10. Distribution: gnu
  11. Message-ID: <m0nGxGl-0000SEC@liberator.lynx.com>
  12.  
  13. Here is a unified diff to fix memory leaks in commands.c:
  14.  
  15. --- commands.c.orig    Tue Jan 26 13:46:57 1993
  16. +++ commands.c    Tue Jan 26 13:48:12 1993
  17. @@ -36,7 +36,7 @@
  18.       register struct file *file;
  19.  {
  20.    register char *p;
  21. -  char *at, *percent, *star, *less;
  22. +  char *at, *percent, *star, *less, *save;
  23.  
  24.  #define    DEFINE_VARIABLE(name, len, value) \
  25.    (void) define_variable_for_file (name, len, value, o_automatic, 0, file)
  26. @@ -56,7 +56,7 @@
  27.  #endif    /* NO_ARCHIVES.  */
  28.      {
  29.        at = savestring (file->name, strlen (file->name));
  30. -      percent = "";
  31. +      percent = savestring ("", 0);
  32.      }
  33.  
  34.    DEFINE_VARIABLE ("@", 1, at);
  35. @@ -64,8 +64,8 @@
  36.  
  37.  #define    LASTSLASH(s)    rindex ((s), '/')
  38.  #define    FILEONLY(s)    (p != 0 ? p + 1 : (s))
  39. -#define    DIRONLY(s)    (p == 0 ? "./" : p == (s) ? "/" \
  40. -             : savestring ((s), (p - (s)) + 1))
  41. +#define    DIRONLY(s)    (p == 0 ? savestring ("./", 2) : p == (s) ? \
  42. +             savestring ("/", 1) : savestring ((s), (p - (s)) + 1))
  43.  
  44.    /* $* is the stem from an implicit or static pattern rule.  */
  45.    if (file->stem == 0)
  46. @@ -118,17 +118,24 @@
  47.  
  48.    /* Set up the D and F versions.  */
  49.    p = LASTSLASH (at);
  50. -  DEFINE_VARIABLE ("@D", 2, DIRONLY (at));
  51. +  DEFINE_VARIABLE ("@D", 2, save = DIRONLY (at));
  52. +  free (save);
  53.    DEFINE_VARIABLE ("@F", 2, FILEONLY (at));
  54.    p = LASTSLASH (star);
  55. -  DEFINE_VARIABLE ("*D", 2, DIRONLY (star));
  56. +  DEFINE_VARIABLE ("*D", 2, save = DIRONLY (star));
  57. +  free (save);
  58.    DEFINE_VARIABLE ("*F", 2, FILEONLY (star));
  59.    p = LASTSLASH (less);
  60. -  DEFINE_VARIABLE ("<D", 2, DIRONLY (less));
  61. +  DEFINE_VARIABLE ("<D", 2, save = DIRONLY (less));
  62. +  free (save);
  63.    DEFINE_VARIABLE ("<F", 2, FILEONLY (less));
  64.    p = LASTSLASH (percent);
  65. -  DEFINE_VARIABLE ("%D", 2, DIRONLY (percent));
  66. +  DEFINE_VARIABLE ("%D", 2, save = DIRONLY (percent));
  67. +  free (save);
  68.    DEFINE_VARIABLE ("%F", 2, FILEONLY (percent));
  69. +
  70. +  free (at);
  71. +  free (percent);
  72.  
  73.    /* Make sure that no dependencies are repeated.  This does not
  74.       really matter for the purpose of updating targets, but it
  75.  
  76.