MCPcopy Create free account
hub / github.com/alibaba/zvec / zvec_string_array_create

Function zvec_string_array_create

src/binding/c/c_api.cc:954–967  ·  view source on GitHub ↗

* @brief Create a string array with given count * @param count Number of strings in the array * @return New string array, or NULL on failure */

Source from the content-addressed store, hash-verified

952 * @return New string array, or NULL on failure
953 */
954zvec_string_array_t *zvec_string_array_create(size_t count) {
955 if (count > SIZE_MAX / sizeof(zvec_string_t)) return nullptr;
956
957 zvec_string_array_t *array = (zvec_string_array_t *)malloc(sizeof(zvec_string_array_t));
958 if (!array) return nullptr;
959 array->count = count;
960 array->strings = (zvec_string_t *)malloc(sizeof(zvec_string_t) * count);
961 if (!array->strings) {
962 free(array);
963 return nullptr;
964 }
965 memset(array->strings, 0, sizeof(zvec_string_t) * count);
966 return array;
967}
968
969/**
970 * @brief Create a string array from C-string array

Calls

no outgoing calls

Tested by 2