* @brief Add a string to string array at specified index * @param array String array to add to * @param idx Index to add at * @param str String to add */
| 992 | * @param str String to add |
| 993 | */ |
| 994 | void zvec_string_array_add(zvec_string_array_t *array, size_t idx, |
| 995 | const char *str) { |
| 996 | if (!array || !str) return; |
| 997 | if (idx >= array->count) return; |
| 998 | size_t len = strlen(str); |
| 999 | char *buf = (char *)malloc(len + 1); |
| 1000 | if (!buf) return; |
| 1001 | memcpy(buf, str, len + 1); |
| 1002 | array->strings[idx].data = buf; |
| 1003 | array->strings[idx].length = len; |
| 1004 | array->strings[idx].capacity = len + 1; |
| 1005 | } |
| 1006 | |
| 1007 | /** |
| 1008 | * @brief Destroy a string array and free all memory |
no outgoing calls