9
0
Fork 0

Add environment variable test; fix several detected bugs

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@298 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2007-06-30 22:39:20 +00:00
parent 41fe6cf685
commit 61e0e742d5
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;