int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype)
{
- int retval, count;
+ int count;
/* First check if we really have something to do */
- if (recvcount == 0) {
- retval = sendcount == 0 ? MPI_SUCCESS : MPI_ERR_TRUNCATE;
- } else {
+ if (recvcount > 0 && recvbuf != sendbuf) {
/* FIXME: treat packed cases */
sendcount *= smpi_datatype_size(sendtype);
recvcount *= smpi_datatype_size(recvtype);
}else{
s_smpi_subtype_t *subtype = sendtype->substruct;
- s_smpi_mpi_vector_t* type_c = (s_smpi_mpi_vector_t*)sendtype;
- void * buf_tmp = malloc(count * type_c->size_oldtype);
+ void * buf_tmp = xbt_malloc(count);
subtype->serialize( sendbuf, buf_tmp,1, subtype);
subtype = recvtype->substruct;
- subtype->unserialize(recvbuf, buf_tmp,1, subtype);
+ subtype->unserialize( buf_tmp, recvbuf,1, subtype);
free(buf_tmp);
}
- retval = sendcount > recvcount ? MPI_ERR_TRUNCATE : MPI_SUCCESS;
}
- return retval;
+ return sendcount > recvcount ? MPI_ERR_TRUNCATE : MPI_SUCCESS;
}
/*
if ((*type)->has_subtype == 1){
((s_smpi_subtype_t *)(*type)->substruct)->subtype_free(type);
+ xbt_free((*type)->substruct);
}
xbt_free(*type);