Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: src/lib/libc



Module Name:    src
Committed By:   tron
Date:           Sun Nov 14 18:11:43 UTC 2010

Modified Files:
        src/lib/libc/compat/stdlib: compat_unsetenv.c
        src/lib/libc/gen: popen.c
        src/lib/libc/misc: initfini.c
        src/lib/libc/stdlib: Makefile.inc getenv.c local.h putenv.c setenv.c
            system.c unsetenv.c
Added Files:
        src/lib/libc/include: env.h
        src/lib/libc/stdlib: _env.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/compat/stdlib/compat_unsetenv.c
cvs rdiff -u -r1.29 -r1.30 src/lib/libc/gen/popen.c
cvs rdiff -u -r0 -r1.1 src/lib/libc/include/env.h
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/misc/initfini.c
cvs rdiff -u -r1.74 -r1.75 src/lib/libc/stdlib/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/lib/libc/stdlib/_env.c
cvs rdiff -u -r1.32 -r1.33 src/lib/libc/stdlib/getenv.c
cvs rdiff -u -r1.5 -r1.6 src/lib/libc/stdlib/local.h
cvs rdiff -u -r1.18 -r1.19 src/lib/libc/stdlib/putenv.c
cvs rdiff -u -r1.42 -r1.43 src/lib/libc/stdlib/setenv.c
cvs rdiff -u -r1.22 -r1.23 src/lib/libc/stdlib/system.c
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/stdlib/unsetenv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Home | Main Index | Thread Index | Old Index