]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
allow NULL pointer arguments in SetDataType
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 15 Nov 2007 14:23:05 +0000 (14:23 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 15 Nov 2007 14:23:05 +0000 (14:23 +0000)
HLT/BASE/AliHLTComponent.cxx
HLT/BASE/AliHLTComponent.h

index fb8c9204ac23d0dd1f4b0b4b3488210725e98b14..6bc94cafaf0b22e72d9b977eee083cf0649bc9b5 100644 (file)
@@ -437,9 +437,15 @@ void AliHLTComponent::CopyDataType(AliHLTComponentDataType& tgtdt, const AliHLTC
 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)
index f413e378de437edfa07f9343db36818bbd38b5a0..2934135b6709c4183bc5537bc55febaf3b06a047 100644 (file)
@@ -461,11 +461,13 @@ class AliHLTComponent : public AliHLTLogging {
    * 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