OpenGrok
Cross Reference: unsetenv.c
xref
: /
src
/
lib
/
libc
/
stdlib
/
unsetenv.c
Home
|
History
|
Annotate
|
Download
|
only in
stdlib
History log of
/src/lib/libc/stdlib/unsetenv.c
Revision
Date
Author
Comments
1.11
20-Jan-2015
christos
Fix non _REENTRANT build.
1.10
14-Nov-2010
tron
Improve and simplify implementation of *env(3) functions:
- Use RB tree to keep track of memory allocated via setenv(3) as
suggested by Enami Tsugutomo in private e-mail.
This simplifies the code a lot as we no longer need to keep the size
of "environ" in sync with an array of allocated environment variables.
It also makes it possible to free environment variables in unsetenv(3)
if something has changed the order of the "environ" array.
- Fix a bug in getenv(3) and getenv_r(3) which would return bogus
results e.g. for " getenv("A=B") " if an environment variable "A"
with value "B=C" exists.
- Clean up the internal functions:
- Don't expose the read/write lock for the environment to other parts
of "libc". Provide locking functions instead.
- Use "bool" to report success or failure.
- Use "ssize_t" or "size_t" instead of "int" for indexes.
- Provide internal functions with simpler interfaces e.g. don't
combine return values and reference arguments.
- Don't copy "environ" into an allocated block unless we really need
to grow it.
Code reviewed by Joerg Sonnenberger and Christos Zoulas, tested by
Joerg Sonnenberger and me. These changes also fix problems in
zsh 4.3.* and pam_ssh according to Joerg.
1.9
30-Sep-2010
tron
Be slightly more careful about freeing memory allocated for environment
variables: only free memory if the current value points to the same
memory area as the allocated block. This will prevent crashes if an
application changes the order of the environment array.
Unfortunately this is still not enough to stop zsh 4.2.* from crashing.
zsh 4.3.* works fine before and after this change.
1.8
29-Sep-2010
enami
Don't put space before close paren.
1.7
25-Sep-2010
tron
Unlock the environment lock if __alocenv() fails.
1.6
25-Sep-2010
tron
Remember memory used by allocated environment variables instead of
using a bitmap. This deals with the case where a variable is first
set via setenv(3) or putenv(3), then overwritten by changing
"environ" directory and afterwards overwritten with setenv(3) again.
This stops "zsh" from crashing under NetBSD-current.
Code reviewed by Christos Zoulas.
1.5
24-Sep-2010
christos
protect the __allocenv call with the mutex; from Enami
1.4
23-Sep-2010
christos
Use a bit array to keep track of malloced environment entries so we can
free them.
1.3
13-Sep-2005
christos
compat core reorg.
1.2
26-Jul-2003
salo
netbsd.org->NetBSD.org
1.1
07-Apr-2003
kleink
1003.1-2001 has introduced unsetenv() which differs from the current
implementation in not permitting a "name=value" argument.
* Add a conforming __unsetenv13() and do function renaming for
unsetenv(); preserve old symbol with old behavior.
* Make visible setenv() and unsetenv() for 1003.1-2001 feature selection
macros; resolves PR standards/20479.
Indexes created Sun Sep 21 20:09:37 GMT 2025