};
class Datatype : public F2C, public Keyval{
- char* name_ = nullptr;
+ std::string name_ = "";
/* The id here is the (unique) datatype id used for this datastructure.
* It's default value is set to -1 since some code expects this return value
* when no other id has been assigned
Datatype& operator=(const Datatype&) = delete;
~Datatype() override;
- char* name() const { return name_; }
+ const char* name() const { return name_.c_str(); }
size_t size() const { return size_; }
MPI_Aint lb() const { return lb_; }
MPI_Aint ub() const { return ub_; }
s4u::MutexPtr mut_;
s4u::Barrier* bar_;
MPI_Win* connected_wins_;
- char* name_;
+ std::string name_;
int opened_;
MPI_Group group_;
int count_; //for ordering the accs
cleanup_attr<Datatype>();
delete contents_;
- xbt_free(name_);
}
int Datatype::copy_attrs(Datatype* datatype){
void Datatype::get_name(char* name, int* length) const
{
- if(name_!=nullptr){
- *length = strlen(name_);
- strncpy(name, name_, *length+1);
- }else{
- *length = 0;
+ *length = name_.length();
+ if (not name_.empty()) {
+ name_.copy(name, *length);
+ name[*length] = '\0';
}
}
-void Datatype::set_name(const char* name){
- if(name_!=nullptr && (flags_ & DT_FLAG_PREDEFINED) == 0)
- xbt_free(name_);
- name_ = xbt_strdup(name);
+void Datatype::set_name(const char* name)
+{
+ name_ = name;
}
int Datatype::pack(const void* inbuf, int incount, void* outbuf, int outcount, int* position, const Comm*)
if(info!=MPI_INFO_NULL)
info->ref();
int comm_size = comm->size();
- name_ = nullptr;
opened_ = 0;
group_ = MPI_GROUP_NULL;
requests_ = new std::vector<MPI_Request>();
delete requests_;
delete[] connected_wins_;
- if (name_ != nullptr){
- xbt_free(name_);
- }
if (info_ != MPI_INFO_NULL)
simgrid::smpi::Info::unref(info_);
if (errhandler_ != MPI_ERRHANDLER_NULL)
void Win::get_name(char* name, int* length) const
{
- if(name_==nullptr){
- *length=0;
- name=nullptr;
- return;
+ *length = name_.length();
+ if (not name_.empty()) {
+ name_.copy(name, *length);
+ name[*length] = '\0';
}
- *length = strlen(name_);
- strncpy(name, name_, *length+1);
}
void Win::get_group(MPI_Group* group){
}
void Win::set_name(const char* name){
- name_ = xbt_strdup(name);
+ name_ = name;
}
int Win::fence(int assert)