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:
parent
41fe6cf685
commit
61e0e742d5
|
@ -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
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue