* @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. */
| 51 | * if buffer is full. |
| 52 | */ |
| 53 | static 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 |
no test coverage detected