apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Poirier <poir...@pobox.com>
Subject Re: apr_env_set use of putenv
Date Mon, 29 Mar 2010 13:36:57 GMT
On 2010-03-29 at 09:16, Graham Leggett <minfrin@sharp.fm> wrote:

> I think registering a proper cleanup to remove the environment
> variable on pool cleanup is the way to go, possibly with the addition
> of apr_env_setn() that sets the environment without a corresponding
> cleanup (ie current behaviour).
> This follows the pattern of apr_table and friends.

I don't think that's the right pattern to follow.  apr_table is used to
allocate a new data structure, owned by the caller, and the caller
certainly should control its lifetime.  apr_env_set() is used to add an
entry to the OS's environment, which the caller does not own and would
not expect to have any control over the lifetime of its entries.

If there's a use case for adding an environment variable with a
limited lifetime, that could be a separate API, but I don't think
changing the behavior of the current API is appropriate.  

I just think it should behave as it does if the platform has setenv(),
and not crash my program at some random time in the future :-)


View raw message