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

Function _strvec_append

components/lwp/lwp_args.c:53–67  ·  view source on GitHub ↗

* @brief Appends a string to a string vector structure * * @param[in,out] sv Pointer to the string vector structure * @param[in] string String to append to the vector * * @return rt_err_t RT_EOK on success, -RT_ENOMEM on memory allocation failure * * @note This function dynamically grows the string vector's buffer into 2 times its current size * if buffer is full. */

Source from the content-addressed store, hash-verified

51 * if buffer is full.
52 */
53static rt_err_t _strvec_append(struct lwp_string_vector *sv, const char *string)
54{
55 if (sv->string_count == sv->strvec_buflen)
56 {
57 void *newptr;
58 newptr = rt_realloc(sv->strvec, sv->strvec_buflen * 2 * sizeof(char *));
59 if (!newptr)
60 return -RT_ENOMEM;
61 sv->strvec = newptr;
62 sv->strvec_buflen *= 2;
63 }
64
65 sv->strvec[sv->string_count++] = string;
66 return RT_EOK;
67}
68
69/**
70 * @brief Appends an argument or environment variable to the LWP arguments info structure

Callers 1

args_appendFunction · 0.85

Calls 1

rt_reallocFunction · 0.85

Tested by

no test coverage detected