From owner-freebsd-current Thu Aug 6 07:48:58 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id HAA15332 for freebsd-current-outgoing; Thu, 6 Aug 1998 07:48:58 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from ns.mt.sri.com (sri-gw.MT.net [206.127.105.141]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id HAA15325 for ; Thu, 6 Aug 1998 07:48:52 -0700 (PDT) (envelope-from nate@mt.sri.com) Received: from mt.sri.com (rocky.mt.sri.com [206.127.76.100]) by ns.mt.sri.com (8.8.8/8.8.8) with SMTP id IAA11587; Thu, 6 Aug 1998 08:47:49 -0600 (MDT) (envelope-from nate@rocky.mt.sri.com) Received: by mt.sri.com (SMI-8.6/SMI-SVR4) id IAA12240; Thu, 6 Aug 1998 08:47:45 -0600 Date: Thu, 6 Aug 1998 08:47:45 -0600 Message-Id: <199808061447.IAA12240@mt.sri.com> From: Nate Williams MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: dg@root.com Cc: Narvi , Bruce Evans , freebsd@xaa.iae.nl, freebsd-current@FreeBSD.ORG Subject: Re: memory leaks in libc In-Reply-To: <199808061238.FAA28204@implode.root.com> References: <199808061238.FAA28204@implode.root.com> X-Mailer: VM 6.29 under 19.15 XEmacs Lucid Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG David wrote: > The problem with fixing setenv() is that you don't know if a pointer > was malloced, allocated from the env area above the stack, points to > read-only text, points to a static data buffer, etc. There really is > no way to know for sure, so you can't free the memory. Bruce responded: > You can know if you malloced it in a previous call to putenv() or setenv(). David replied: > Perhaps Bruce is suggesting that a seperate array be allocated to keep > track of whether or not an env pointer was malloced? This would be very > costly and, IMO, not worth it considering how rarely memory is lost by > not freeing previously malloced strings. Very costly? Could you do almost all of it in the userland libraries, and would be pretty cost-free, especially considering it would only have much effect if the user did lots of environment allocations? Nate To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message