2007-06-30 19:05:44 +02:00
|
|
|
/****************************************************************************
|
2014-08-08 21:53:29 +02:00
|
|
|
* sched/environ/env_release.c
|
2007-06-30 19:05:44 +02:00
|
|
|
*
|
2021-02-08 16:33:58 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2007-06-30 19:05:44 +02:00
|
|
|
*
|
2021-02-08 16:33:58 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-06-30 19:05:44 +02:00
|
|
|
*
|
2021-02-08 16:33:58 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2007-06-30 19:05:44 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#ifndef CONFIG_DISABLE_ENVIRON
|
|
|
|
|
|
|
|
#include <sched.h>
|
2021-05-18 08:59:14 +02:00
|
|
|
#include <assert.h>
|
2007-06-30 19:05:44 +02:00
|
|
|
#include <errno.h>
|
2014-08-09 02:39:28 +02:00
|
|
|
|
|
|
|
#include <nuttx/kmalloc.h>
|
|
|
|
|
2014-08-08 21:53:29 +02:00
|
|
|
#include "environ/environ.h"
|
2007-06-30 19:05:44 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2012-07-14 21:30:31 +02:00
|
|
|
* Name: env_release
|
2007-06-30 19:05:44 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2013-01-26 00:21:27 +01:00
|
|
|
* env_release() is called only from group_leave() when the last member of
|
|
|
|
* a task group exits. The env_release() function clears the environment
|
|
|
|
* of all name-value pairs and sets the value of the external variable
|
|
|
|
* environ to NULL.
|
2012-07-14 21:30:31 +02:00
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2018-08-10 18:16:39 +02:00
|
|
|
* group - Identifies the task group containing the environment structure
|
|
|
|
* to be released.
|
2007-06-30 19:05:44 +02:00
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2013-01-26 00:21:27 +01:00
|
|
|
* None
|
2007-06-30 19:05:44 +02:00
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Not called from an interrupt handler
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-01-27 00:49:02 +01:00
|
|
|
void env_release(FAR struct task_group_s *group)
|
2007-06-30 19:05:44 +02:00
|
|
|
{
|
2018-08-10 18:16:39 +02:00
|
|
|
DEBUGASSERT(group != NULL);
|
2007-06-30 19:05:44 +02:00
|
|
|
|
2013-01-26 00:21:27 +01:00
|
|
|
/* Free any allocate environment strings */
|
2007-06-30 19:05:44 +02:00
|
|
|
|
2013-01-26 00:21:27 +01:00
|
|
|
if (group->tg_envp)
|
|
|
|
{
|
|
|
|
/* Free the environment */
|
2012-07-14 21:30:31 +02:00
|
|
|
|
2020-04-07 16:31:47 +02:00
|
|
|
kumm_free(group->tg_envp);
|
2007-06-30 19:05:44 +02:00
|
|
|
}
|
2012-07-14 21:30:31 +02:00
|
|
|
|
2020-02-23 09:50:23 +01:00
|
|
|
/* In any event, make sure that all environment-related variables in the
|
2013-01-26 00:21:27 +01:00
|
|
|
* task group structure are reset to initial values.
|
|
|
|
*/
|
|
|
|
|
|
|
|
group->tg_envsize = 0;
|
|
|
|
group->tg_envp = NULL;
|
2007-06-30 19:05:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_DISABLE_ENVIRON */
|