+ if (((recvdisps[i]+recvcounts[i])*dt_size_recv) > maxsize)
+ maxsize=(recvdisps[i]+recvcounts[i])*dt_size_recv;
+ }
+
+ if( sendbuf == MPI_IN_PLACE ) {
+ sendtmpbuf = static_cast<void*>(xbt_malloc(maxsize));
+ memcpy(sendtmpbuf,recvbuf, maxsize);
+ sendtmpcounts= static_cast<int*>(xbt_malloc(size*sizeof(int)));
+ memcpy(sendtmpcounts,recvcounts, size*sizeof(int));
+ sendtmpdisps= static_cast<int*>(xbt_malloc(size*sizeof(int)));
+ memcpy(sendtmpdisps,recvdisps, size*sizeof(int));
+ sendtmptype=recvtype;
+ }
+
+ extra->datatype1 = encode_datatype(sendtmptype, &known);
+ int dt_size_send = 1;
+ dt_size_send = smpi_datatype_size(sendtmptype);
+
+ for(i=0; i< size; i++){//copy data to avoid bad free
+ extra->send_size += sendtmpcounts[i]*dt_size_send;
+ extra->sendcounts[i] = sendtmpcounts[i]*dt_size_send;