Skip to content

Commit

Permalink
enhance the dup arr funciton
Browse files Browse the repository at this point in the history
  • Loading branch information
MamziB committed Feb 6, 2025
1 parent f451356 commit 956409a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/utils/ucc_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,16 @@ ucc_status_t ucc_config_names_array_dup(ucc_config_names_array_t *dst,
const ucc_config_names_array_t *src)
{
int i;
if (dst->names != NULL) {
ucc_config_names_array_free(dst);
}

if (dst->names == NULL) {
dst->names = ucc_malloc(sizeof(char*) * src->count, "ucc_config_names_array");
ucc_error("allocating dst->names %p \n", dst->names);
if (!dst->names) {
ucc_error("failed to allocate %zd bytes for ucc_config_names_array",
sizeof(char *) * src->count);
return UCC_ERR_NO_MEMORY;
}
dst->names = ucc_malloc(sizeof(char*) * src->count, "ucc_config_names_array");
ucc_error("allocating dst->names %p \n", dst->names);
if (!dst->names) {
ucc_error("failed to allocate %zd bytes for ucc_config_names_array",
sizeof(char *) * src->count);
return UCC_ERR_NO_MEMORY;
}
dst->count = src->count;
for (i = 0; i < src->count; i++) {
Expand All @@ -272,6 +273,7 @@ void ucc_config_names_array_free(ucc_config_names_array_t *array)
free(array->names[i]);
}
ucc_free(array->names);
array->names = NULL;
}

int ucc_config_names_search(const ucc_config_names_array_t *config_names,
Expand Down

0 comments on commit 956409a

Please sign in to comment.