1
1

Be more careful with datatype names.

This commit was SVN r5833.
Этот коммит содержится в:
Jeff Squyres 2005-05-23 21:45:20 +00:00
родитель 913c0d2f87
Коммит 905bf85295
2 изменённых файлов: 6 добавлений и 3 удалений

Просмотреть файл

@ -48,9 +48,12 @@ int MPI_Type_get_name(MPI_Datatype type, char *type_name, int *resultlen)
}
}
/* Simple */
/* Simple. Copy over the entire name (including all blanks at the
end) because a) the user must have passed us a string of at
least length MPI_MAX_OBJECT_LEN, and b) if this is a call from
Fortran, the string may require null padding on the right. */
*resultlen = strlen(type->name);
strncpy( type_name, type->name, *resultlen );
strncpy(type_name, type->name, MPI_MAX_OBJECT_NAME);
return MPI_SUCCESS;
}

Просмотреть файл

@ -48,11 +48,11 @@ int MPI_Type_set_name (MPI_Datatype type, char *type_name)
}
}
memset(type->name, 0, MPI_MAX_OBJECT_NAME);
length = strlen( type_name );
if( length >= MPI_MAX_OBJECT_NAME ) {
length = MPI_MAX_OBJECT_NAME - 1;
}
strncpy( type->name, type_name, length );
type->name[length + 1] = '\0';
return MPI_SUCCESS;
}