From dev-return-23163-apmail-apr-dev-archive=apr.apache.org@apr.apache.org Fri Apr 23 12:33:49 2010 Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 55853 invoked from network); 23 Apr 2010 12:33:49 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 23 Apr 2010 12:33:49 -0000 Received: (qmail 76844 invoked by uid 500); 23 Apr 2010 12:33:48 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 76771 invoked by uid 500); 23 Apr 2010 12:33:47 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 76764 invoked by uid 99); 23 Apr 2010 12:33:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Apr 2010 12:33:47 +0000 X-ASF-Spam-Status: No, hits=-1.0 required=10.0 tests=AWL,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of apr-dev@m.gmane.org designates 80.91.229.12 as permitted sender) Received: from [80.91.229.12] (HELO lo.gmane.org) (80.91.229.12) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Apr 2010 12:33:41 +0000 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1O5I4L-0006XQ-Af for dev@apr.apache.org; Fri, 23 Apr 2010 14:33:17 +0200 Received: from bi01p1.nc.us.ibm.com ([129.33.49.251]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 23 Apr 2010 14:33:17 +0200 Received: from poirier by bi01p1.nc.us.ibm.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 23 Apr 2010 14:33:17 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: dev@apr.apache.org connect(): No such file or directory From: Dan Poirier Subject: Re: apr_env_set use of putenv Date: Fri, 23 Apr 2010 08:33:07 -0400 Lines: 27 Message-ID: References: <05D9D8EB-F320-4C9B-BC9A-EEC27401C94D@sharp.fm> <648AFB5742D6394FB956DC606975560559CA04C5@OLFANDEXCH01.andover.olf.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: bi01p1.nc.us.ibm.com User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (darwin) Cancel-Lock: sha1:u4j5rOoOQIrz+DmpzhQtLOZM9Yk= On 2010-04-22 at 19:18, Ed Holyat wrote: > - Windows automatically copies and controls the memory with _putenv, > allocating a copy on Windows should not be done. > > - Unix requires a memory allocation, you can free the memory in the > environment if you clear the environment variable. > > e.g. UNIX > > mymem=strdup("FOO=abc"); > putenv(mymem); > putenv("FOO="); > free(mymem); > > In my opinion it is not worth the coding effort to keep track of the > environment variables you set and then freeing them. Environment > variables should be set once and used for the life of the program they > are not meant to be set and unset over and over again. UNIX should > just be putenv(strdup("FOO=abc"));//set it and forget it. Another factor to consider - this is only an issue on systems that don't have setenv(). setenv() is in POSIX and the single Unix Spec v3, so the number of systems this would affect is likely a minority, and getting smaller each year. Dan