From owner-freebsd-hackers@FreeBSD.ORG Fri Feb 25 01:39:41 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C214D16A4CE for ; Fri, 25 Feb 2005 01:39:41 +0000 (GMT) Received: from mail.farley.org (farley.org [67.64.95.201]) by mx1.FreeBSD.org (Postfix) with ESMTP id 57CBA43D2F for ; Fri, 25 Feb 2005 01:39:41 +0000 (GMT) (envelope-from sean-freebsd@farley.org) Received: from thor.farley.org (thor.farley.org [IPv6:2001:470:1f01:290:1::5]) by mail.farley.org (8.13.1/8.13.1) with ESMTP id j1P1dZh7002513; Thu, 24 Feb 2005 19:39:35 -0600 (CST) (envelope-from sean-freebsd@farley.org) Received: from localhost (localhost [127.0.0.1]) by thor.farley.org (8.13.1/8.13.1) with ESMTP id j1P1dgwZ046662; Thu, 24 Feb 2005 19:39:42 -0600 (CST) (envelope-from sean-freebsd@farley.org) Date: Thu, 24 Feb 2005 19:39:42 -0600 (CST) From: =?ISO-8859-1?Q?Se=E1n_C=2E_Farley?= To: =?iso-8859-1?q?Dag-Erling_Sm=F8rgrav?= In-Reply-To: <86ekf65ssx.fsf@xps.des.no> Message-ID: <20050224174015.D45516@thor.farley.org> References: <20050222173013.B26342@thor.farley.org> <863bvnmyrt.fsf@xps.des.no> <20050223140733.T35108@thor.farley.org> <86ekf65ssx.fsf@xps.des.no> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-895816517-1109288758=:45516" Content-ID: <20050224193913.I46648@thor.farley.org> cc: freebsd-hackers@freebsd.org Subject: Re: setenv/unsetenv's known memory leak X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Feb 2005 01:39:41 -0000 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --0-895816517-1109288758=:45516 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-1; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Content-ID: <20050224183507.Q46189@thor.farley.org> On Thu, 24 Feb 2005, Dag-Erling Sm=F8rgrav wrote: > Se=E1n C. Farley writes: >> How does this version look? > > Needlessly complicated. I'd just copy the entire environment into > malloc()ed space the first time setenv() or putenv() is called. I like complicated. :) I have written a new version that makes copies of all variables within the environment upon the first run of setenv(). Here are the two versions I have written to stop the memory leak. Old (complex): http://www.farley.org/freebsd/tmp/setenv-1.tar.bz2 New (simple): http://www.farley.org/freebsd/tmp/setenv-2.tar.bz2 Se=E1n --=20 sean-freebsd@farley.org --0-895816517-1109288758=:45516--