void AliHLTComponent::SetDataType(AliHLTComponentDataType& tgtdt, const char* id, const char* origin)
{
// see header file for function documentation
- tgtdt=kAliHLTVoidDataType;
- strncpy(&tgtdt.fID[0], id, kAliHLTComponentDataTypefIDsize);
- strncpy(&tgtdt.fOrigin[0], origin, kAliHLTComponentDataTypefOriginSize);
+ tgtdt.fStructSize=sizeof(AliHLTComponentDataType);
+ if (id) {
+ memset(&tgtdt.fID[0], 0, kAliHLTComponentDataTypefIDsize);
+ strncpy(&tgtdt.fID[0], id, strlen(id)<kAliHLTComponentDataTypefIDsize?strlen(id):kAliHLTComponentDataTypefIDsize);
+ }
+ if (origin) {
+ memset(&tgtdt.fOrigin[0], 0, kAliHLTComponentDataTypefOriginSize);
+ strncpy(&tgtdt.fOrigin[0], origin, strlen(origin)<kAliHLTComponentDataTypefOriginSize?strlen(origin):kAliHLTComponentDataTypefOriginSize);
+ }
}
void AliHLTComponent::FillEventData(AliHLTComponentEventData& evtData)
* Set the ID and Origin of an AliHLTComponentDataType structure.
* The function sets the fStructureSize member and copies the strings
* to the ID and Origin. Only characters from the valid part of the string
- * are copied, the rest is fille with 0's.
+ * are copied, the rest is filled with 0's. <br>
* Please note that the fID and fOrigin members are not strings, just arrays of
* chars of size @ref kAliHLTComponentDataTypefIDsize and
* @ref kAliHLTComponentDataTypefOriginSize respectively and not necessarily with
- * a terminating zero.
+ * a terminating zero. <br>
+ * It is possible to pass NULL pointers as id or origin argument, in that case they
+ * are just ignored.
* @param tgtdt target data type structure
* @param id ID string
* @param origin Origin string