🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #1102

memory leak in gnu make 3.62

#1102
From: J.T. Conklin
Date: Mon, 16 Nov 1992 23:24
27 lines
1572 bytes
The following patch allocates storage on the stack in the DIRONLY
macro, rather than using the savestring function().  The macro is
a tiny bit uglier, but it doesn't waste memory.

Performance should not suffer since good compilers will recognize that
"(p - (s))" is a common subexpression.

diff -c make/commands.c:1.1.1.1 make/commands.c:1.3
*** make/commands.c:1.1.1.1	Mon Nov 16 15:12:56 1992
--- make/commands.c	Mon Nov 16 15:12:56 1992
***************
*** 65,71 ****
  #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))
  
    /* $* is the stem from an implicit or static pattern rule.  */
    if (file->stem == 0)
--- 65,71 ----
  #define	LASTSLASH(s)	rindex ((s), '/')
  #define	FILEONLY(s)	(p != 0 ? p + 1 : (s))
  #define	DIRONLY(s)	(p == 0 ? "./" : p == (s) ? "/" \
! 			 : strncpy(alloca((p - (s)) + 1), s, (p - (s))))
  
    /* $* is the stem from an implicit or static pattern rule.  */
    if (file->stem == 0)
Technical Details
Message-ID: <9211162324.AA06414@talisman.kaleida.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!talisman.kaleida.com!conklin

Show Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!talisman.kaleida.com!conklin
From: conklin@talisman.kaleida.com (J.T. Conklin)
Subject: memory leak in gnu make 3.62
Message-ID: <9211162324.AA06414@talisman.kaleida.com>
Sender: gnulists@ai.mit.edu
Reply-To: conklin@kaleida.com
Organization: GNUs Not Usenet
Distribution: gnu
Date: Mon, 16 Nov 1992 23:24:10 GMT
Approved: bug-gnu-utils@prep.ai.mit.edu
Lines: 28