Add environment variable test; fix several detected bugs

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@298 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2007-06-30 22:39:20 +00:00
parent c418e219ac
commit cdd8fe239a
4 changed files with 9 additions and 5 deletions

View File

@ -191,6 +191,8 @@
* Add environment variables APIs: environ, getenv, putenv, clearenv, setenv,
unsetenv
* Correct an error in realloc() when the block is extended "down" in memory.
In this case, the old memory contents need to be copied to the new location.
In this case, the old memory contents need to be copied to the new location
and an allocated bit was not being set.
* examples/ostest: Added an environment variable test.
* Started m68322

View File

@ -628,7 +628,9 @@ Other memory:
* Add environment variables APIs: environ, getenv, putenv, clearenv, setenv,
unsetenv
* Correct an error in realloc() when the block is extended "down" in memory.
In this case, the old memory contents need to be copied to the new location.
In this case, the old memory contents need to be copied to the new location
and an allocated bit was not being set.
* examples/ostest: Added an environment variable test.
* Started m68322
</pre></ul>

View File

@ -99,7 +99,7 @@ int env_dup(FAR _TCB *ptcb)
{
/* Yes..The parent task has an environment, duplicate it */
size_t envlen = ptcb->envp->ev_alloc;
size_t envlen = parent->envp->ev_alloc;
envp = (environ_t*)malloc(SIZEOF_ENVIRON_T( envlen ));
if (!envp)
{
@ -109,7 +109,7 @@ int env_dup(FAR _TCB *ptcb)
{
envp->ev_crefs = 1;
envp->ev_alloc = envlen;
memcmp( envp->ev_env, ptcb->envp->ev_env, envlen );
memcpy( envp->ev_env, parent->envp->ev_env, envlen );
}
}

View File

@ -100,7 +100,7 @@ FAR char *getenv(const char *name)
/* Check if the variable exists */
if ( envp && (pvar = env_findvar(envp, name)) != NULL)
if ( !envp || (pvar = env_findvar(envp, name)) == NULL)
{
ret = ENOENT;
goto errout_with_lock;