X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Factions%2Fpath.cpp;h=41fb92e27bddfc2e599a72807e9de7feefaeb216;hb=1ad48d9678f8f123dc7d44dbbfadc9957b7e970e;hp=816f2cd219cd49d865270136e68cacf2617a8c7d;hpb=a6bc4ca9d659caf016ef932fcd944029737ac57c;p=lttng-tools.git diff --git a/src/common/actions/path.cpp b/src/common/actions/path.cpp index 816f2cd21..41fb92e27 100644 --- a/src/common/actions/path.cpp +++ b/src/common/actions/path.cpp @@ -5,12 +5,14 @@ * */ -#include +#include +namespace { struct lttng_action_path_comm { uint32_t index_count; uint64_t indexes[]; } LTTNG_PACKED; +} /* namespace */ struct lttng_action_path *lttng_action_path_create( const uint64_t *indexes, size_t index_count) @@ -23,7 +25,7 @@ struct lttng_action_path *lttng_action_path_create( goto error; } - path = (lttng_action_path *) zmalloc(sizeof(*path)); + path = zmalloc(); if (!path) { goto error; } @@ -96,32 +98,25 @@ end: } int lttng_action_path_copy(const struct lttng_action_path *src, - struct lttng_action_path *dst) + struct lttng_action_path **dst) { int ret; - size_t i, src_count; + struct lttng_action_path *new_path; LTTNG_ASSERT(src); LTTNG_ASSERT(dst); - lttng_dynamic_array_init(&dst->indexes, sizeof(uint64_t), NULL); - src_count = lttng_dynamic_array_get_count(&src->indexes); - - for (i = 0; i < src_count; i++) { - const void *index = lttng_dynamic_array_get_element( - &src->indexes, i); - - ret = lttng_dynamic_array_add_element(&dst->indexes, index); - if (ret) { - goto error; - } + new_path = lttng_action_path_create( + (uint64_t *) lttng_dynamic_array_get_element( + &src->indexes, 0), + lttng_dynamic_array_get_count(&src->indexes)); + if (!new_path) { + ret = -1; + } else { + ret = 0; + *dst = new_path; } - ret = 0; - goto end; -error: - lttng_dynamic_array_reset(&dst->indexes); -end: return ret; }