Date: Mon, 14 May 2001 16:54:03 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: Waldemar Schultz cc: djgpp AT delorie DOT com Subject: Re: getenv() question In-Reply-To: <3AFFC9F0.A428D3CB@ma.tum.de> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Mon, 14 May 2001, Waldemar Schultz wrote: > After srarting a DOS session there normally are set some > environment variables like PATH COMMAND etc. > now I want to start an application, that is known to set some > by itself eg. 290 bytes via putenv() or in a batch wrapper. > What I was thinking of, is to determine the free space in the > DOS environment before actually launching the application, > to be able to tell the user he should increase > the 'shell= ... /E:xxx' setting in his config.sys in case the > free space were less than the needed 290 bytes. Ah, so you are concerned about launching a subordinate command.com or some other program? In that case, you don't need to worry: the way DJGPP spawns programs, there's always enough space in the environment block for _all_ of the environment variables recorded in the environ[] array, including any variables added by the program. (In fact, each DJGPP program adds some variables to environment when its startup code reads djgpp.env.) This works because the `spawn*' family of functions allocates enough space in conventional memory to store all the environment variables when it gets ready to launch a subsidiary program. Unless you have more variables than the 16KB transfer buffer can hold, you are safe. (If the transfer buffer is not large enough, `spawn*' functions will refuse to run the program.) In other words, DJGPP programs and all the subprograms they invoke do not inherit the fixed size of their parent COMMAND.COM's environment block.