diff --git a/include/fmpi_domain.h b/include/fmpi_domain.h index 25c4f32702194e783d518b900fdb49cda4fcaac7..0b640d29ab3c87922d8a243b53c4c9c5d1ca7b4f 100644 --- a/include/fmpi_domain.h +++ b/include/fmpi_domain.h @@ -42,7 +42,7 @@ struct fmpi_ctx; * TODO */ typedef struct fmpi_domain { - struct fmpi_data data; //!< Data composing the domain. + const struct fmpi_data * data; //!< Data composing the domain. struct fmpi_data * parts; //!< Partitions of the domain after decomposition. size_t part_cnt; //!< Number of partitions. } fmpi_domain; @@ -52,7 +52,9 @@ typedef struct fmpi_domain { /*------------------------------------------------------------------------------ fmpi_new_domain() ------------------------------------------------------------------------------*/ -struct fmpi_domain fmpi_new_domain(const struct fmpi_ctx * ctx, struct fmpi_data data); +struct fmpi_domain fmpi_new_domain( + const struct fmpi_ctx * ctx, const struct fmpi_data * data +); /*============================================================================== GUARD ==============================================================================*/ diff --git a/src/fmpi_domain.c b/src/fmpi_domain.c index 23cab5185fc77c9b0734f709165f43d6b19551b5..63a8c21184068853dc4cb88311ad0986e171a14b 100644 --- a/src/fmpi_domain.c +++ b/src/fmpi_domain.c @@ -25,7 +25,8 @@ #include "fmpi_domain.h" // C Standard Library #include <assert.h> -#include <stdlib.h> // size_t, NULL, malloc() +#include <stdlib.h> // size_t, NULL, malloc(), free() +#include <string.h> // memcpy() // Internal #include "fmpi_data.h" #include "internal/fmpi_ctx.h" @@ -51,7 +52,7 @@ static struct fmpi_data * fmpi_partition_block_1d( fmpi_new_domain() ------------------------------------------------------------------------------*/ struct fmpi_domain fmpi_new_domain( - const struct fmpi_ctx * const ctx, const struct fmpi_data data) + const struct fmpi_ctx * const ctx, const struct fmpi_data * const data) { assert(ctx != NULL); const size_t proc_cnt = (size_t)ctx->mpi->size; @@ -60,7 +61,7 @@ struct fmpi_domain fmpi_new_domain( .parts = NULL, .part_cnt = proc_cnt }; - domain.parts = fmpi_partition_block_1d(ctx, &data); + domain.parts = fmpi_partition_block_1d(ctx, data); if(domain.parts == NULL) { FMPI_RAISE_ERROR(ctx->err_handler, "FMPI", "fmpi_partition_block_1d() failed!"); }