xiaoxiang781216 commented on code in PR #20583: URL: https://github.com/apache/nuttx/pull/20583#discussion_r4302213870
########## libs/libc/environ/env_alloc.c: ########## @@ -0,0 +1,140 @@ +/**************************************************************************** + * libs/libc/environ/env_alloc.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <assert.h> +#include <errno.h> +#include <string.h> + +#include <nuttx/tls.h> + +#include "environ/environ.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: env_alloc + ****************************************************************************/ + +FAR void *env_alloc(FAR struct task_info_s *info, size_t size) +{ + FAR struct env_block_s *block; + + block = env_malloc(info, sizeof(*block) + size); + if (block == NULL) + { + return NULL; + } + + block->flink = info->ta_envmem; + info->ta_envmem = block; + return block + 1; +} + +/**************************************************************************** + * Name: env_drop + ****************************************************************************/ + +void env_drop(FAR struct task_info_s *info, FAR void *mem) +{ + FAR struct env_block_s *block = (FAR struct env_block_s *)mem - 1; + FAR struct env_block_s **prev; + + for (prev = (FAR struct env_block_s **)&info->ta_envmem; + *prev != NULL; + prev = &(*prev)->flink) + { + if (*prev == block) + { + *prev = block->flink; + env_free(info, block); + return; + } + } + + DEBUGPANIC(); +} + +/**************************************************************************** + * Name: env_reserve + ****************************************************************************/ + +int env_reserve(FAR struct task_info_s *info, ssize_t more) +{ + FAR char **envp = info->ta_envp; + FAR char **arr; + ssize_t envc = 0; + ssize_t envpc; Review Comment: yes, please. BTW, could you squash the last patch into one? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
