MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / args_init

Function args_init

components/lwp/lwp_args.c:243–269  ·  view source on GitHub ↗

* @brief implementation for initializing a light-weight process arguments info structure * * @param[in,out] ai Pointer to the arguments info structure to initialize * @param[in] str_buf_size Size of the string buffer to allocate * * @return rt_err_t * - RT_EOK on successful initialization * - -RT_ENOMEM if memory allocation fails */

Source from the content-addressed store, hash-verified

241 * - -RT_ENOMEM if memory allocation fails
242 */
243static rt_err_t args_init(struct lwp_args_info *ai, size_t str_buf_size)
244{
245 void *str_buf;
246 str_buf = rt_malloc(str_buf_size);
247 if (!str_buf)
248 return -RT_ENOMEM;
249
250 memset(ai, 0, sizeof(*ai));
251
252 _strvec_init(&ai->argv);
253 if (!ai->argv.strvec)
254 {
255 rt_free(str_buf);
256 return -RT_ENOMEM;
257 }
258 _strvec_init(&ai->envp);
259 if (!ai->envp.strvec)
260 {
261 rt_free(str_buf);
262 _strvec_detach(&ai->argv);
263 return -RT_ENOMEM;
264 }
265
266 ai->str_buf_size = str_buf_size;
267 ai->str_buf = str_buf;
268 return RT_EOK;
269}
270
271#define STR_BUF_DEFAULT_SIZE 2048
272

Callers 2

lwp_args_initFunction · 0.85
lwp_args_load_scriptFunction · 0.85

Calls 4

rt_mallocFunction · 0.85
_strvec_initFunction · 0.85
rt_freeFunction · 0.85
_strvec_detachFunction · 0.85

Tested by

no test coverage detected