(file) Return to SCMO.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/SCMO.cpp between version 1.2.2.33 and 1.24

version 1.2.2.33, 2009/09/30 15:51:28 version 1.24, 2013/02/13 11:39:58
Line 27 
Line 27 
 // //
 ////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
 // //
   // This code implements part of PEP#348 - The CMPI infrastructure using SCMO
   // (Single Chunk Memory Objects).
   // The design document can be found on the OpenPegasus website openpegasus.org
   // at https://collaboration.opengroup.org/pegasus/pp/documents/21210/PEP_348.pdf
   //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <Pegasus/Common/SCMO.h> #include <Pegasus/Common/SCMO.h>
Line 42 
Line 47 
 #include <Pegasus/Common/CIMNameCast.h> #include <Pegasus/Common/CIMNameCast.h>
 #include <Pegasus/Common/CommonUTF.h> #include <Pegasus/Common/CommonUTF.h>
 #include <Pegasus/Common/StrLit.h> #include <Pegasus/Common/StrLit.h>
   #include <Pegasus/Common/Tracer.h>
 #include <Pegasus/Common/XmlWriter.h> #include <Pegasus/Common/XmlWriter.h>
 #include <Pegasus/Common/System.h> #include <Pegasus/Common/System.h>
 #include <Pegasus/Common/FileSystem.h> #include <Pegasus/Common/FileSystem.h>
 #include <Pegasus/Common/StringConversion.h> #include <Pegasus/Common/StringConversion.h>
 #include <Pegasus/Common/ArrayIterator.h> #include <Pegasus/Common/ArrayIterator.h>
 #include <Pegasus/Common/PegasusAssert.h> #include <Pegasus/Common/PegasusAssert.h>
   #include <Pegasus/Common/CIMValueRep.h>
   
   # if defined PEGASUS_OS_ZOS
 #include <strings.h> #include <strings.h>
   # else
   #  include <string.h>
   # endif
  
 #ifdef PEGASUS_OS_ZOS #ifdef PEGASUS_OS_ZOS
   #include <Pegasus/General/SetFileDescriptorToEBCDICEncoding.h>   #include <Pegasus/General/SetFileDescriptorToEBCDICEncoding.h>
 #endif #endif
  
   #ifdef PEGASUS_HAS_ICU
   # include <unicode/platform.h>
   # include <unicode/urename.h>
   # include <unicode/ures.h>
   # include <unicode/ustring.h>
   # include <unicode/uchar.h>
   # include <unicode/ucnv.h>
   #endif
   
 PEGASUS_USING_STD; PEGASUS_USING_STD;
  
 #define SCMB_INITIAL_MEMORY_CHUNK_SIZE 4096 #define SCMB_INITIAL_MEMORY_CHUNK_SIZE 4096
Line 67 
Line 88 
  */  */
 #define NULLSTR(x) ((x) == 0 ? "" : (x)) #define NULLSTR(x) ((x) == 0 ? "" : (x))
  
 #define NEWCIMSTR(ptr,base) \  
       ((ptr).length == 0 ?  \  
       (String()) :           \  
       (String(&(base)[(ptr).start],((ptr).length)-1)))  
   
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
   #define PEGASUS_ARRAY_T SCMOInstance
   # include "ArrayImpl.h"
   #undef PEGASUS_ARRAY_T
   
 const StrLit SCMOClass::_qualifierNameStrLit[72] = const StrLit SCMOClass::_qualifierNameStrLit[72] =
 { {
     STRLIT(""),     STRLIT(""),
Line 153 
Line 173 
 #define _NUM_QUALIFIER_NAMES \ #define _NUM_QUALIFIER_NAMES \
            (sizeof(_qualifierNameStrLit)/sizeof(_qualifierNameStrLit[0]))            (sizeof(_qualifierNameStrLit)/sizeof(_qualifierNameStrLit[0]))
  
   
 /***************************************************************************** /*****************************************************************************
  * Internal inline functions.   * The static declaration of the common SCMO memory functions.
  *****************************************************************************/  *****************************************************************************/
  
 inline SCMOClass* _getSCMOClass(const CIMObjectPath& theCIMObj)  static Uint64 _getFreeSpace(
 {      SCMBDataPtr& ptr,
       Uint32 size,
       SCMBMgmt_Header** pmem);
  
     if (theCIMObj.getClassName().isNull())  static void _setString(
     {      const String& theString,
         // this is an empty ObjectPath      SCMBDataPtr& ptr,
         return 0;      SCMBMgmt_Header** pmem);
     }  
  
     // TODO: If there is a case, where no name space is provided at  static void _setBinary(
     //       the object path, the ns has to be routed at setting      const void* theBuffer,
     //       CIMTYPE_REFERENCE, CIMTYPE_INSTANCE, CIMTYPE_OBJECT      Uint32 bufferSize,
     PEGASUS_DEBUG_ASSERT(!theCIMObj.getNameSpace().isNull());      SCMBDataPtr& ptr,
       SCMBMgmt_Header** pmem);
  
     CString nameSpace = theCIMObj.getNameSpace().getString().getCString();  
     CString clsName = theCIMObj.getClassName().getString().getCString();  
  
     SCMOClassCache* theCache = SCMOClassCache::getInstance();  
     SCMOClass* theClass = theCache->getSCMOClass(  
         (const char*)nameSpace,strlen(nameSpace),  
         (const char*)clsName,strlen(clsName));  
  
     if (theClass == 0)  /*****************************************************************************
    * Internal inline functions.
    *****************************************************************************/
   
   inline String _newCimString(const SCMBDataPtr & ptr, const char * base)
     {     {
         throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_CLASS,      if (ptr.size > 0)
            theCIMObj.toString());      {
           return String(&(base[ptr.start]),ptr.size-1);
       }
       else
       {
           return String();
     }     }
     return theClass;  
 } }
  
 inline void _deleteArrayExtReference( inline void _deleteArrayExtReference(
Line 194 
Line 219 
     SCMBUnion* ptr;     SCMBUnion* ptr;
     // if the array was already set,     // if the array was already set,
     // the previous references has to be deleted     // the previous references has to be deleted
     if(theArray.length != 0)      if(theArray.size != 0)
     {     {
         Uint32 oldArraySize=(theArray.length/sizeof(SCMBUnion));          Uint32 oldArraySize=(theArray.size/sizeof(SCMBUnion));
  
         ptr = (SCMBUnion*)&(((char*)*pmem)[theArray.start]);         ptr = (SCMBUnion*)&(((char*)*pmem)[theArray.start]);
         for (Uint32 i = 0 ; i < oldArraySize ; i++)         for (Uint32 i = 0 ; i < oldArraySize ; i++)
         {         {
             delete ptr[i].extRefPtr;             delete ptr[i].extRefPtr;
               ptr[i].extRefPtr = 0;
         }         }
     }     }
 } }
  
   static void _deleteExternalReferenceInternal(
 /*****************************************************************************      SCMBMgmt_Header* memHdr, SCMOInstance *extRefPtr)
  * The SCMOClass methods  
  *****************************************************************************/  
 SCMOClass::SCMOClass()  
 { {
     cls.mem = 0;      Uint32 nuExtRef = memHdr->numberExtRef;
 }      char * base = ((char*)memHdr);
       Uint64* array =
           (Uint64*)&(base[memHdr->extRefIndexArray.start]);
       Uint32 extRefIndex = PEG_NOT_FOUND;
  
 void SCMOClass::_destroyExternalReferences()      for (Uint32 i = 0; i < nuExtRef; i++)
 { {
     // TODO: Has to be optimized not to loop through all props.           if (((SCMBUnion*)(&(base[array[i]])))->extRefPtr == extRefPtr)
     // Address the property array           {
     SCMBClassPropertyNode* nodeArray =               extRefIndex = i;
         (SCMBClassPropertyNode*)               break;
             &(cls.base[cls.hdr->propertySet.nodeArray.start]);           }
       }
       PEGASUS_ASSERT (extRefIndex != PEG_NOT_FOUND);
  
     SCMBValue* theValue;     // Shrink extRefIndexArray
  
     for (Uint32 i = 0; i < cls.hdr->propertySet.number; i++)      for (Uint32 i = extRefIndex + 1; i < nuExtRef; i++)
     {     {
         theValue = &(nodeArray[i].theProperty.defaultValue);          array[i-1] = array[i];
       }
  
         // if not an NULL value !      array[nuExtRef-1] = 0;
         if(!theValue->flags.isNull)      memHdr->numberExtRef--;
         {  
             if (theValue->valueType == CIMTYPE_REFERENCE ||      delete extRefPtr;
                 theValue->valueType == CIMTYPE_OBJECT ||  
                 theValue->valueType == CIMTYPE_INSTANCE )  
             {  
                 if (theValue->flags.isArray)  
                 {  
                     _deleteArrayExtReference(  
                         theValue->value.arrayValue,  
                         &cls.mem);  
                 }                 }
                 else  
   /*****************************************************************************
    * The SCMOClass methods
    *****************************************************************************/
   SCMOClass::SCMOClass()
                 {                 {
                     delete theValue->value.extRefPtr;      _initSCMOClass();
                 }  // end is Array  
             } // end is ext. reference.      _setBinary("",1,cls.hdr->className,&cls.mem );
         }// end is not null      _setBinary("",1,cls.hdr->nameSpace,&cls.mem );
     }// loop throug all properties      cls.hdr->flags.isEmpty=true;
 } }
  
 inline void SCMOClass::_initSCMOClass() inline void SCMOClass::_initSCMOClass()
Line 279 
Line 304 
  
 } }
  
   SCMOClass::SCMOClass(const char* className, const char* nameSpaceName )
   {
       Uint32 clsNameLen = strlen(className);
       Uint32 nsNameLen = strlen(nameSpaceName);
   
       if (0 == className )
       {
           String message("SCMOClass: Class name not set (null pointer)!");
           throw CIMException(CIM_ERR_FAILED,message );
       }
   
       if (0 == nameSpaceName)
       {
           String message("SCMOClass: Name Space not set (null pointer)!");
           throw CIMException(CIM_ERR_FAILED,message );
       }
   
       _initSCMOClass();
   
       _setBinary(className,clsNameLen+1,cls.hdr->className,&cls.mem );
   
       _setBinary(nameSpaceName,nsNameLen+1,cls.hdr->nameSpace,&cls.mem );
   
       cls.hdr->flags.isEmpty=true;
   
   }
   
 SCMOClass::SCMOClass( SCMOClass::SCMOClass(
     const CIMClass& theCIMClass,     const CIMClass& theCIMClass,
     const char* nameSpaceName)     const char* nameSpaceName)
Line 296 
Line 348 
     {     {
         // there is no Super ClassName         // there is no Super ClassName
         cls.hdr->superClassName.start=0;         cls.hdr->superClassName.start=0;
         cls.hdr->superClassName.length=0;          cls.hdr->superClassName.size=0;
     }     }
  
     CIMObjectPath theObjectPath=theCIMClass.getPath();     CIMObjectPath theObjectPath=theCIMClass.getPath();
Line 329 
Line 381 
  
 } }
  
   void SCMOClass::_destroyExternalReferences()
   {
       _destroyExternalReferencesInternal(cls.mem);
   }
   
   const char* SCMOClass::getSuperClassName() const
   {
       return _getCharString(cls.hdr->superClassName,cls.base);
   }
   
   const char* SCMOClass::getSuperClassName_l(Uint32 & length) const
   {
       length = cls.hdr->superClassName.size;
       if (0 == length)
       {
           return 0;
       }
       else
       {
           length--;
       }
       return _getCharString(cls.hdr->superClassName,cls.base);
   }
   
 void  SCMOClass::getCIMClass(CIMClass& cimClass) const void  SCMOClass::getCIMClass(CIMClass& cimClass) const
 { {
     CIMClass newCimClass(     CIMClass newCimClass(
         CIMNameCast(NEWCIMSTR(cls.hdr->className,cls.base)),          CIMNameCast(_newCimString(cls.hdr->className,cls.base)),
         CIMNameCast(NEWCIMSTR(cls.hdr->superClassName,cls.base)));          CIMNameCast(_newCimString(cls.hdr->superClassName,cls.base)));
  
     // set the name space     // set the name space
     newCimClass._rep->_reference._rep->_nameSpace=     newCimClass._rep->_reference._rep->_nameSpace=
         CIMNamespaceNameCast(NEWCIMSTR(cls.hdr->nameSpace,cls.base));          CIMNamespaceNameCast(_newCimString(cls.hdr->nameSpace,cls.base));
  
     // Add class qualifier if exist     // Add class qualifier if exist
     if (0 != cls.hdr->numberOfQualifiers)     if (0 != cls.hdr->numberOfQualifiers)
Line 393 
Line 469 
     if (0 != clsProp.theProperty.originClassName.start)     if (0 != clsProp.theProperty.originClassName.start)
     {     {
         retCimProperty = CIMProperty(         retCimProperty = CIMProperty(
             CIMNameCast(NEWCIMSTR(clsProp.theProperty.name,cls.base)),              CIMNameCast(_newCimString(clsProp.theProperty.name,cls.base)),
             theCimValue,             theCimValue,
             theCimValue.getArraySize(),             theCimValue.getArraySize(),
             CIMNameCast(NEWCIMSTR(clsProp.theProperty.refClassName,cls.base)),              CIMNameCast(
             CIMNameCast(NEWCIMSTR(                  _newCimString(clsProp.theProperty.refClassName,cls.base)),
                 clsProp.theProperty.originClassName,cls.base)),              CIMNameCast(
                   _newCimString(clsProp.theProperty.originClassName,cls.base)),
             clsProp.theProperty.flags.propagated);             clsProp.theProperty.flags.propagated);
     }     }
     else     else
     {     {
          retCimProperty = CIMProperty(          retCimProperty = CIMProperty(
             CIMNameCast(NEWCIMSTR(clsProp.theProperty.name,cls.base)),              CIMNameCast(_newCimString(clsProp.theProperty.name,cls.base)),
             theCimValue,             theCimValue,
             theCimValue.getArraySize(),             theCimValue.getArraySize(),
             CIMNameCast(NEWCIMSTR(clsProp.theProperty.refClassName,cls.base)),              CIMNameCast(
                   _newCimString(clsProp.theProperty.refClassName,cls.base)),
             CIMName(),             CIMName(),
             clsProp.theProperty.flags.propagated);             clsProp.theProperty.flags.propagated);
     }     }
Line 449 
Line 527 
  
     if (scmbQualifier.name == QUALNAME_USERDEFINED)     if (scmbQualifier.name == QUALNAME_USERDEFINED)
     {     {
         theCimQualiName = NEWCIMSTR(scmbQualifier.userDefName,base);          theCimQualiName = _newCimString(scmbQualifier.userDefName,base);
     }     }
     else     else
     {     {
Line 472 
Line 550 
  
     keyNames.clear();     keyNames.clear();
  
     for (Uint32 i = 0, k = cls.hdr->propertySet.number; i < k; i++)      for (Uint32 i = 0, k = cls.hdr->keyBindingSet.number; i < k; i++)
     {     {
         // Append the key property name.         // Append the key property name.
         // The length has to be reduces by 1 not to copy the trailing '\0'          keyNames.append(_newCimString(nodeArray[i].name,cls.base));
         keyNames.append(  
             String((const char*)_getCharString(nodeArray[i].name,cls.base),  
                    nodeArray[i].name.length-1));  
   
     }     }
 } }
  
Line 501 
Line 575 
     tag = _generateStringTag((const char*)name, len);     tag = _generateStringTag((const char*)name, len);
     // get the node index of the hash table     // get the node index of the hash table
     hashIdx =     hashIdx =
         cls.hdr->keyBindingSet.hashTable[tag%PEGASUS_KEYBINDIG_SCMB_HASHSIZE];        cls.hdr->keyBindingSet.hashTable[tag&(PEGASUS_KEYBINDIG_SCMB_HASHSIZE-1)];
     // there is no entry in the hash table on this hash table index.     // there is no entry in the hash table on this hash table index.
     if (hashIdx == 0)     if (hashIdx == 0)
     {     {
Line 524 
Line 598 
         if (nodeArray[node].nameHashTag == tag)         if (nodeArray[node].nameHashTag == tag)
         {         {
             // Now it is worth to compare the two names             // Now it is worth to compare the two names
             if (_equalUTF8Strings(              if (_equalNoCaseUTF8Strings(nodeArray[node].name,cls.base,name,len))
                 nodeArray[node].name,cls.base,name,len))  
             {             {
                 // we found the property !                 // we found the property !
                 return SCMO_OK;                 return SCMO_OK;
Line 557 
Line 630 
     tag = _generateStringTag((const char*)name, len);     tag = _generateStringTag((const char*)name, len);
     // get the node index of the hash table     // get the node index of the hash table
     hashIdx =     hashIdx =
         cls.hdr->propertySet.hashTable[tag%PEGASUS_PROPERTY_SCMB_HASHSIZE];        cls.hdr->propertySet.hashTable[tag&(PEGASUS_PROPERTY_SCMB_HASHSIZE -1)];
     // there is no entry in the hash table on this hash table index.     // there is no entry in the hash table on this hash table index.
     if (hashIdx == 0)     if (hashIdx == 0)
     {     {
Line 580 
Line 653 
         if (nodeArray[node].theProperty.nameHashTag == tag)         if (nodeArray[node].theProperty.nameHashTag == tag)
         {         {
             // Now it is worth to compare the two names             // Now it is worth to compare the two names
             if (_equalUTF8Strings(              if (_equalNoCaseUTF8Strings(
                 nodeArray[node].theProperty.name,cls.base,name,len))                 nodeArray[node].theProperty.name,cls.base,name,len))
             {             {
                 // we found the property !                 // we found the property !
Line 600 
Line 673 
     } while ( true );     } while ( true );
  
     // this should never be reached     // this should never be reached
     return SCMO_NOT_FOUND;      PEGASUS_UNREACHABLE(return SCMO_NOT_FOUND;)
   
 } }
  
 void SCMOClass::_setClassProperties(PropertySet& theCIMProperties) void SCMOClass::_setClassProperties(PropertySet& theCIMProperties)
Line 611 
Line 683 
     Uint32 noKeys = 0;     Uint32 noKeys = 0;
     Boolean isKey = false;     Boolean isKey = false;
  
     Uint32 keyIndex[noProps];      Array<Uint32> keyIndex(noProps);
  
     cls.hdr->propertySet.number=noProps;     cls.hdr->propertySet.number=noProps;
  
Line 619 
Line 691 
     startKeyIndexList = _getFreeSpace(     startKeyIndexList = _getFreeSpace(
         cls.hdr->keyIndexList,         cls.hdr->keyIndexList,
         noProps*sizeof(Uint32),         noProps*sizeof(Uint32),
         &cls.mem,          &cls.mem);
         true);  
  
     if(noProps != 0)     if(noProps != 0)
     {     {
Line 634 
Line 705 
         // (68 - 1) / 64 = 1 --> The mask consists of two Uint64 values.         // (68 - 1) / 64 = 1 --> The mask consists of two Uint64 values.
         _getFreeSpace(cls.hdr->keyPropertyMask,         _getFreeSpace(cls.hdr->keyPropertyMask,
               sizeof(Uint64)*(((noProps-1)/64)+1),               sizeof(Uint64)*(((noProps-1)/64)+1),
               &cls.mem,true);                &cls.mem);
  
         // allocate property array and save the start index of the array.         // allocate property array and save the start index of the array.
         start = _getFreeSpace(cls.hdr->propertySet.nodeArray,         start = _getFreeSpace(cls.hdr->propertySet.nodeArray,
                       sizeof(SCMBClassPropertyNode)*noProps,                       sizeof(SCMBClassPropertyNode)*noProps,
                       &cls.mem,true);                        &cls.mem);
  
         // clear the hash table         // clear the hash table
         memset(cls.hdr->propertySet.hashTable,         memset(cls.hdr->propertySet.hashTable,
Line 682 
Line 753 
             // fill the key index list             // fill the key index list
             memcpy(             memcpy(
                 &(cls.base[startKeyIndexList]),                 &(cls.base[startKeyIndexList]),
                 keyIndex,                  keyIndex.getData(),
                 noKeys*sizeof(Uint32));                 noKeys*sizeof(Uint32));
  
             for (Uint32 i = 0 ; i < noKeys; i++)             for (Uint32 i = 0 ; i < noKeys; i++)
Line 699 
Line 770 
         else         else
         {         {
             cls.hdr->keyBindingSet.nodeArray.start=0;             cls.hdr->keyBindingSet.nodeArray.start=0;
             cls.hdr->keyBindingSet.nodeArray.length=0;              cls.hdr->keyBindingSet.nodeArray.size=0;
         }         }
     }     }
     else     else
     {     {
         cls.hdr->propertySet.nodeArray.start=0;         cls.hdr->propertySet.nodeArray.start=0;
         cls.hdr->propertySet.nodeArray.length=0;          cls.hdr->propertySet.nodeArray.size=0;
         cls.hdr->keyPropertyMask.start=0;         cls.hdr->keyPropertyMask.start=0;
         cls.hdr->keyPropertyMask.length=0;          cls.hdr->keyPropertyMask.size=0;
         cls.hdr->keyBindingSet.nodeArray.start=0;         cls.hdr->keyBindingSet.nodeArray.start=0;
         cls.hdr->keyBindingSet.nodeArray.length=0;          cls.hdr->keyBindingSet.nodeArray.size=0;
     }     }
 } }
  
Line 725 
Line 796 
  
     Uint32 *hashTable = cls.hdr->keyBindingSet.hashTable;     Uint32 *hashTable = cls.hdr->keyBindingSet.hashTable;
  
     if ( newIndex >= cls.hdr->keyBindingSet.number)  
     {  
         throw IndexOutOfBoundsException();  
     }  
   
     // calculate the new hash index of the new property.     // calculate the new hash index of the new property.
     Uint32 hash = newKeyNode->nameHashTag % PEGASUS_KEYBINDIG_SCMB_HASHSIZE;      Uint32 hash = newKeyNode->nameHashTag &
           (PEGASUS_KEYBINDIG_SCMB_HASHSIZE - 1);
  
     // 0 is an invalid index in the hash table     // 0 is an invalid index in the hash table
     if (hashTable[hash] == 0)     if (hashTable[hash] == 0)
Line 781 
Line 848 
  
     Uint32 *hashTable = cls.hdr->propertySet.hashTable;     Uint32 *hashTable = cls.hdr->propertySet.hashTable;
  
     if ( newIndex >= cls.hdr->propertySet.number)  
     {  
         throw IndexOutOfBoundsException();  
     }  
   
     // calcuate the new hash index of the new property.     // calcuate the new hash index of the new property.
     Uint32 hash = newPropNode->theProperty.nameHashTag %      Uint32 hash = newPropNode->theProperty.nameHashTag &
         PEGASUS_PROPERTY_SCMB_HASHSIZE;          (PEGASUS_PROPERTY_SCMB_HASHSIZE -1);
  
     // 0 is an invalid index in the hash table     // 0 is an invalid index in the hash table
     if (hashTable[hash] == 0)     if (hashTable[hash] == 0)
Line 831 
Line 893 
     const CIMProperty& theCIMProperty)     const CIMProperty& theCIMProperty)
 { {
     CIMPropertyRep* propRep = theCIMProperty._rep;     CIMPropertyRep* propRep = theCIMProperty._rep;
     Uint64 valueStart;  
  
     // First do all _setString(). Can cause reallocation.     // First do all _setString(). Can cause reallocation.
     _setString(propRep->_name.getString(),     _setString(propRep->_name.getString(),
Line 861 
Line 922 
  
     // Create a filter to set the bit.     // Create a filter to set the bit.
     // Modulo division with 64. Shift left a bit by the remainder.     // Modulo division with 64. Shift left a bit by the remainder.
     Uint64 filter = ( (Uint64)1 << (i%64));      Uint64 filter = ( (Uint64)1 << (i & 63));
  
     // Calculate the real pointer to the Uint64 array     // Calculate the real pointer to the Uint64 array
     keyMask = (Uint64*)&cls.base[cls.hdr->keyPropertyMask.start];      keyMask = (Uint64*)&(cls.base[cls.hdr->keyPropertyMask.start]);
  
     keyMask[idx] = keyMask[idx] | filter ;     keyMask[idx] = keyMask[idx] | filter ;
 } }
Line 881 
Line 942 
  
     // Create a filter to check if the bit is set:     // Create a filter to check if the bit is set:
     // Modulo division with 64. Shift left a bit by the remainder.     // Modulo division with 64. Shift left a bit by the remainder.
     Uint64 filter = ( (Uint64)1 << (i%64));      Uint64 filter = ( (Uint64)1 << (i & 63));
  
     // Calculate the real pointer to the Uint64 array     // Calculate the real pointer to the Uint64 array
     keyMask = (Uint64*)&cls.base[cls.hdr->keyPropertyMask.start];      keyMask = (Uint64*)&(cls.base[cls.hdr->keyPropertyMask.start]);
  
     return keyMask[idx] & filter ;     return keyMask[idx] & filter ;
  
Line 980 
Line 1041 
     else     else
     {     {
         scmoPropNode->theProperty.qualifierArray.start=0;         scmoPropNode->theProperty.qualifierArray.start=0;
         scmoPropNode->theProperty.qualifierArray.length=0;          scmoPropNode->theProperty.qualifierArray.size=0;
     }     }
  
     return isKey;     return isKey;
Line 1011 
Line 1072 
     else     else
     {     {
         cls.hdr->qualifierArray.start=0;         cls.hdr->qualifierArray.start=0;
         cls.hdr->qualifierArray.length=0;          cls.hdr->qualifierArray.size=0;
     }     }
 } }
  
Line 1044 
Line 1105 
     return name;     return name;
 } }
  
 void SCMOClass::_setValue(Uint64 start, const CIMValue& theCIMValue)  void SCMOClass::_setValue(
       Uint64 start,
       const CIMValue& theCIMValue)
 { {
     Uint64 valueStart;     Uint64 valueStart;
  
Line 1055 
Line 1118 
     scmoValue->valueArraySize = 0;     scmoValue->valueArraySize = 0;
     scmoValue->flags.isNull = rep->isNull;     scmoValue->flags.isNull = rep->isNull;
     scmoValue->flags.isArray = rep->isArray;     scmoValue->flags.isArray = rep->isArray;
     scmoValue->flags.isSet = true;      scmoValue->flags.isSet = false;
  
     if (rep->isNull)     if (rep->isNull)
     {     {
Line 1072 
Line 1135 
             rep->type,             rep->type,
             // Is set to the number of array members by the function.             // Is set to the number of array members by the function.
             scmoValue->valueArraySize,             scmoValue->valueArraySize,
               cls.hdr->nameSpace.start,
               cls.hdr->nameSpace.size,
             rep->u);             rep->u);
     }     }
     else     else
Line 1080 
Line 1145 
             valueStart,             valueStart,
             &cls.mem,             &cls.mem,
             rep->type,             rep->type,
               cls.hdr->nameSpace.start,
               cls.hdr->nameSpace.size,
             rep->u);             rep->u);
     }     }
 } }
Line 1121 
Line 1188 
        (SCMBClassPropertyNode*)        (SCMBClassPropertyNode*)
            &(cls.base[cls.hdr->propertySet.nodeArray.start]);            &(cls.base[cls.hdr->propertySet.nodeArray.start]);
  
    return(_equalUTF8Strings(     return(_equalNoCaseUTF8Strings(
        nodeArray[node].theProperty.originClassName,        nodeArray[node].theProperty.originClassName,
        cls.base,        cls.base,
        origin,        origin,
        len));        len));
 } }
  
 inline SCMO_RC SCMOClass::_isNodeSameType(  SCMO_RC SCMOClass::_isNodeSameType(
     Uint32 node,     Uint32 node,
     CIMType type,     CIMType type,
     Boolean isArray) const      Boolean isArray,
       CIMType& realType) const
 { {
   
     SCMBClassPropertyNode* nodeArray =     SCMBClassPropertyNode* nodeArray =
         (SCMBClassPropertyNode*)         (SCMBClassPropertyNode*)
             &(cls.base[cls.hdr->propertySet.nodeArray.start]);             &(cls.base[cls.hdr->propertySet.nodeArray.start]);
  
       // The type stored in the class information is set on realType.
       // It must be used in further calls to guaranty consistence.
       realType = nodeArray[node].theProperty.defaultValue.valueType;
  
     if(nodeArray[node].theProperty.defaultValue.valueType != type)     if(nodeArray[node].theProperty.defaultValue.valueType != type)
     {     {
           // Accept an property of type instance also
           // for an CIMTYPE_OBJECT property.
           if (!(type == CIMTYPE_INSTANCE &&
                 nodeArray[node].theProperty.defaultValue.valueType
                 == CIMTYPE_OBJECT))
           {
         return SCMO_WRONG_TYPE;         return SCMO_WRONG_TYPE;
     }     }
       }
  
     if (isArray)     if (isArray)
     {     {
Line 1164 
Line 1243 
     return SCMO_OK;     return SCMO_OK;
  
 } }
   
 /***************************************************************************** /*****************************************************************************
  * The SCMOInstance methods  * The SCMOInstance methods
  *****************************************************************************/  *****************************************************************************/
Line 1173 
Line 1253 
     inst.base = 0;     inst.base = 0;
 } }
  
 SCMOInstance::SCMOInstance(SCMOClass baseClass)  SCMOInstance::SCMOInstance(SCMOClass& baseClass)
 { {
     _initSCMOInstance(new SCMOClass(baseClass));     _initSCMOInstance(new SCMOClass(baseClass));
 } }
  
 SCMOInstance::SCMOInstance( SCMOInstance::SCMOInstance(
     SCMOClass baseClass,      SCMOClass& baseClass,
     Boolean includeQualifiers,     Boolean includeQualifiers,
     Boolean includeClassOrigin,      Boolean includeClassOrigin)
     const char** propertyList)  
 { {
  
     _initSCMOInstance(new SCMOClass(baseClass));     _initSCMOInstance(new SCMOClass(baseClass));
Line 1190 
Line 1269 
     inst.hdr->flags.includeQualifiers=includeQualifiers;     inst.hdr->flags.includeQualifiers=includeQualifiers;
     inst.hdr->flags.includeClassOrigin=includeClassOrigin;     inst.hdr->flags.includeClassOrigin=includeClassOrigin;
  
     setPropertyFilter(propertyList);  
   
 } }
  
 SCMOInstance::SCMOInstance(SCMOClass baseClass, const CIMObjectPath& cimObj)  SCMOInstance::SCMOInstance(SCMOClass& baseClass, const CIMObjectPath& cimObj)
 { {
     _initSCMOInstance(new SCMOClass(baseClass));     _initSCMOInstance(new SCMOClass(baseClass));
  
     _setCIMObjectPath(cimObj);     _setCIMObjectPath(cimObj);
 } }
  
 SCMOInstance::SCMOInstance(SCMOClass baseClass, const CIMInstance& cimInstance)  SCMOInstance::SCMOInstance(SCMOClass& baseClass, const CIMInstance& cimInstance)
 { {
  
     _initSCMOInstance(new SCMOClass(baseClass));     _initSCMOInstance(new SCMOClass(baseClass));
Line 1210 
Line 1287 
  
 } }
  
   SCMOInstance::SCMOInstance(CIMClass& theCIMClass, const char* altNameSpace)
   {
       _initSCMOInstance(new SCMOClass(theCIMClass,altNameSpace));
   
   }
   
   SCMOInstance::SCMOInstance(
       const CIMInstance& cimInstance,
       const char* altNameSpace,
       Uint32 altNSLen)
   {
       SCMOClass theSCMOClass = _getSCMOClass(
           cimInstance._rep->_reference,
           altNameSpace,
           altNSLen);
   
       _initSCMOInstance( new SCMOClass(theSCMOClass));
   
       if(theSCMOClass.isEmpty())
       {
           // flag the instance as compromized
           inst.hdr->flags.isCompromised=true;
       }
       else
       {
           _setCIMInstance(cimInstance);
       }
   }
   
   SCMOInstance::SCMOInstance(
       const CIMObject& cimObject,
       const char* altNameSpace,
       Uint32 altNSLen)
   {
       if (cimObject.isClass())
       {
           CIMClass cimClass(cimObject);
   
           _initSCMOInstance(new SCMOClass(cimClass,altNameSpace));
   
           inst.hdr->flags.isClassOnly=true;
       }
       else
       {
           CIMInstance cimInstance(cimObject);
   
           SCMOClass theSCMOClass = _getSCMOClass(
               cimInstance._rep->_reference,
               altNameSpace,
               altNSLen);
   
           _initSCMOInstance( new SCMOClass(theSCMOClass));
   
           if(theSCMOClass.isEmpty())
           {
               // flag the instance as compromized
               inst.hdr->flags.isCompromised=true;
           }
           else
           {
               _setCIMInstance(cimInstance);
           }
       }
   }
   
   SCMOInstance::SCMOInstance(
       const CIMObjectPath& cimObj,
       const char* altNameSpace,
       Uint32 altNSLen)
   {
       SCMOClass theSCMOClass = _getSCMOClass(
           cimObj,
           altNameSpace,
           altNSLen);
   
       _initSCMOInstance( new SCMOClass(theSCMOClass));
   
       if(theSCMOClass.isEmpty())
       {
           // flag the instance as compromized
           inst.hdr->flags.isCompromised=true;
       }
       else
       {
           _setCIMObjectPath(cimObj);
       }
   }
   
 void SCMOInstance::_destroyExternalReferences() void SCMOInstance::_destroyExternalReferences()
 { {
     // TODO: Has to be optimized not to loop through all props.      _destroyExternalReferencesInternal(inst.mem);
     // create a pointer to keybinding node array of the class.  }
     Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;  
   SCMOClass SCMOInstance::_getSCMOClass(
       const CIMObjectPath& theCIMObj,
       const char* altNS,
       Uint32 altNSlength)
   {
       SCMOClass theClass;
   
       if (theCIMObj.getClassName().isNull())
       {
           return SCMOClass();
       }
   
       if (theCIMObj.getNameSpace().isNull())
       {
           // the name space of the object path is empty,
           // use alternative name space.
           CString clsName = theCIMObj.getClassName().getString().getCString();
   
           SCMOClassCache* theCache = SCMOClassCache::getInstance();
           theClass = theCache->getSCMOClass(
               altNS,
               altNSlength,
               (const char*)clsName,
               strlen(clsName));
       }
       else
       {
           CString nameSpace = theCIMObj.getNameSpace().getString().getCString();
           CString clsName = theCIMObj.getClassName().getString().getCString();
   
           SCMOClassCache* theCache = SCMOClassCache::getInstance();
           theClass = theCache->getSCMOClass(
               (const char*)nameSpace,
               strlen(nameSpace),
               (const char*)clsName,
               strlen(clsName));
       }
   
       return theClass;
   }
   
   #define PEGASUS_SIZE_REFERENCE_INDEX_ARRAY 8
   
   void SCMOInstance::_setExtRefIndex(SCMBUnion* pInst, SCMBMgmt_Header** pmem)
   {
   
       Uint64 refPtr =(((char *)pInst) - (char *)(*pmem));
       SCMBMgmt_Header* memHdr = (*pmem);
       // Save the number of external references in the array
       Uint32 noExtRef = memHdr->numberExtRef;
   
       // Allocate the external reflerence array
       // if it is full or empty ( 0 == 0 ).
       if (noExtRef == memHdr->sizeExtRefIndexArray)
       {
           Uint64 oldArrayStart = memHdr->extRefIndexArray.start;
           Uint32 newSize =
               memHdr->sizeExtRefIndexArray + PEGASUS_SIZE_REFERENCE_INDEX_ARRAY;
   
           // Allocate the external reference index array
           _getFreeSpace(
                 memHdr->extRefIndexArray,
                 sizeof(Uint64)*newSize,
                 pmem);
   
           // reset the pointer. It could be changed due to reallocation !
           memHdr = (*pmem);
   
           // Assign new size.
           memHdr->sizeExtRefIndexArray=newSize;
   
           // Get absolute pointer to old index array.
           Uint64* oldArray = (Uint64*)&(((char*)(*pmem))[oldArrayStart]);
           // Get absolute pointer to new index array
           Uint64* newArray =
               (Uint64*)&(((char*)(*pmem))[memHdr->extRefIndexArray.start]);
   
           // Copy all elements of the old array to the new.
           // If noExtRef = 0, no elements are copied.
           for (Uint32 i = 0 ; i < noExtRef ; i++)
           {
               newArray[i] = oldArray[i];
           }
       }
   
       // Get absolute pointer to the array
       Uint64* array =
           (Uint64*)&(((char*)(*pmem))[memHdr->extRefIndexArray.start]);
       // look in the table if the index is already in the array
       for (Uint32 i = 0 ; i < noExtRef ; i++)
       {
           // is the index already part of the array
           if (array[i] == refPtr)
           {
               // leave.
               return;
           }
       }
       // It is not part of the array -> set the new index.
       array[noExtRef] = refPtr;
       // increment the nuber of external references of this instance.
       memHdr->numberExtRef++;
   
   }
   
   SCMOInstance* SCMOInstance::getExtRef(Uint32 idx) const
   {
       Uint64* array =
           (Uint64*)&(inst.base[inst.mem->extRefIndexArray.start]);
       SCMBUnion* pUnion;
       pUnion = (SCMBUnion*)(&(inst.base[array[idx]]));
       return pUnion->extRefPtr;
   }
   
   void SCMOInstance::putExtRef(Uint32 idx,SCMOInstance* ptr)
   {
       Uint64* array =
           (Uint64*)&(inst.base[inst.mem->extRefIndexArray.start]);
       SCMBUnion* pUnion;
       pUnion = (SCMBUnion*)(&(inst.base[array[idx]]));
       pUnion->extRefPtr = ptr;
   }
   
   void SCMOInstance::_copyExternalReferences()
   {
       Uint32 number = inst.mem->numberExtRef;
   
       if (0 != number)
       {
           SCMBUnion* pUnion;
           Uint64* array =
               (Uint64*)&(inst.base[inst.mem->extRefIndexArray.start]);
           for (Uint32 i = 0; i < number; i++)
           {
               pUnion = (SCMBUnion*)(&(inst.base[array[i]]));
               if (0 != pUnion)
               {
                   pUnion->extRefPtr = new SCMOInstance(*(pUnion->extRefPtr));
               }
           }
   
       }
   
   }
   
   void SCMOInstance::_destroyExternalKeyBindings()
   {
       // Create a pointer to keybinding node array of the class.
       Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->keyBindingSet.nodeArray.start;
     SCMBKeyBindingNode* theClassKeyBindNodeArray =     SCMBKeyBindingNode* theClassKeyBindNodeArray =
         (SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]);          (SCMBKeyBindingNode*)&((inst.hdr->theClass.ptr->cls.base)[idx]);
  
     // create a pointer to instanc key binding array.     // create a pointer to instanc key binding array.
     SCMBKeyBindingValue* theInstanceKeyBindingNodeArray =     SCMBKeyBindingValue* theInstanceKeyBindingNodeArray =
Line 1229 
Line 1543 
             // only references can be a key binding             // only references can be a key binding
             if (theClassKeyBindNodeArray[i].type == CIMTYPE_REFERENCE)             if (theClassKeyBindNodeArray[i].type == CIMTYPE_REFERENCE)
             {             {
                delete theInstanceKeyBindingNodeArray[i].data.extRefPtr;                 _deleteExternalReferenceInternal(
                      inst.mem,
                      theInstanceKeyBindingNodeArray[i].data.extRefPtr);
             }             }
         }         }
     }// for all key bindings     }// for all key bindings
  
     SCMBValue* theInstPropArray =      // Are there user defined key bindings ?
         (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);      if (0 != inst.hdr->numberUserKeyBindings)
   
     for (Uint32 i = 0; i < inst.hdr->numberProperties; i++)  
     {     {
         // was the property set by the provider ?          SCMBUserKeyBindingElement* theUserDefKBElement =
         if(theInstPropArray[i].flags.isSet)              (SCMBUserKeyBindingElement*)
                    &(inst.base[inst.hdr->userKeyBindingElement.start]);
   
           for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindings; i++)
         {         {
             // is the property type reference,instance or object?              if (theUserDefKBElement->value.isSet)
             if (theInstPropArray[i].valueType == CIMTYPE_REFERENCE ||  
                 theInstPropArray[i].valueType == CIMTYPE_OBJECT ||  
                 theInstPropArray[i].valueType == CIMTYPE_INSTANCE )  
             {             {
                 if (theInstPropArray[i].flags.isArray)                  // only references can be a key binding.
                   if (theUserDefKBElement->type == CIMTYPE_REFERENCE)
                 {                 {
                     _deleteArrayExtReference(                     _deleteExternalReferenceInternal(
                         theInstPropArray[i].value.arrayValue,                         inst.mem,
                         &inst.mem);                         theUserDefKBElement->value.data.extRefPtr);
                   }
               }
   
               theUserDefKBElement =
                   (SCMBUserKeyBindingElement*)
                        &(inst.base[theUserDefKBElement->nextElement.start]);
           } // for all user def. key bindings.
                 }                 }
                 else  
                 {  
                     delete theInstPropArray[i].value.extRefPtr;  
                 } // end is arry  
             } // end is reference  
         }// end is set  
     } // for all properties.  
 } }
  
 SCMO_RC SCMOInstance::getCIMInstance(CIMInstance& cimInstance) const SCMO_RC SCMOInstance::getCIMInstance(CIMInstance& cimInstance) const
 { {
  
     SCMO_RC rc = SCMO_OK;     SCMO_RC rc = SCMO_OK;
     Uint32 noProps;  
     CIMObjectPath objPath;     CIMObjectPath objPath;
  
     // For better usability define pointers to SCMO Class data structures.     // For better usability define pointers to SCMO Class data structures.
     SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr;      SCMBClass_Main* clshdr = inst.hdr->theClass.ptr->cls.hdr;
     char* clsbase = inst.hdr->theClass->cls.base;      char* clsbase = inst.hdr->theClass.ptr->cls.base;
  
     getCIMObjectPath(objPath);     getCIMObjectPath(objPath);
  
Line 1298 
Line 1612 
         }         }
     }     }
  
     if (inst.hdr->flags.isFiltered)      if (inst.hdr->flags.exportSetOnly)
     {  
         // Get absolut pointer to property filter index map of the instance  
         Uint32* propertyFilterIndexMap =  
             (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);  
   
         for(Uint32 i = 0, k = inst.hdr->filterProperties; i<k; i++)  
         {  
             // Get absolut pointer to property filter index map  
             // of the instance get the real node index of the property.  
             CIMProperty theProperty=_getCIMPropertyAtNodeIndex(  
                 propertyFilterIndexMap[i]);  
   
             newInstance._rep->_properties.append(theProperty);  
         }  
   
     }  
     else  
     {     {
         for(Uint32 i = 0, k = inst.hdr->numberProperties; i<k; i++)         for(Uint32 i = 0, k = inst.hdr->numberProperties; i<k; i++)
         {         {
             // no filtering. Counter is node index              SCMBValue* theInstPropArray =
                   (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
   
               // was the property set by the provider ?
               if(theInstPropArray[i].flags.isSet)
               {
                   // no filtering. Counter is node index
             CIMProperty theProperty=_getCIMPropertyAtNodeIndex(i);             CIMProperty theProperty=_getCIMPropertyAtNodeIndex(i);
  
             newInstance._rep->_properties.append(theProperty);             newInstance._rep->_properties.append(theProperty);
         }         }
           }
       }
       else
       {
           for(Uint32 i = 0, k = inst.hdr->numberProperties; i<k; i++)
           {
               // Set all properties in the CIMInstance gegarding they
               // are part of the SCMOInstance or the SCMOClass.
               CIMProperty theProperty=_getCIMPropertyAtNodeIndex(i);
  
               newInstance._rep->_properties.append(theProperty);
           }
     }     }
  
     cimInstance = newInstance;     cimInstance = newInstance;
Line 1334 
Line 1648 
  
 void SCMOInstance::getCIMObjectPath(CIMObjectPath& cimObj) const void SCMOInstance::getCIMObjectPath(CIMObjectPath& cimObj) const
 { {
       Array<CIMKeyBinding> keys;
     CIMObjectPath newObjectPath;  
  
     // For better usability define pointers to SCMO Class data structures.     // For better usability define pointers to SCMO Class data structures.
     SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr;      SCMBClass_Main* clshdr = inst.hdr->theClass.ptr->cls.hdr;
     char* clsbase = inst.hdr->theClass->cls.base;      char* clsbase = inst.hdr->theClass.ptr->cls.base;
  
     // Address the class keybinding information     // Address the class keybinding information
     SCMBKeyBindingNode* scmoClassArray =     SCMBKeyBindingNode* scmoClassArray =
         (SCMBKeyBindingNode*)&clsbase[clshdr->keyBindingSet.nodeArray.start];          (SCMBKeyBindingNode*)&(clsbase[clshdr->keyBindingSet.nodeArray.start]);
  
     // Address the instance keybinding information     // Address the instance keybinding information
     SCMBKeyBindingValue* scmoInstArray =     SCMBKeyBindingValue* scmoInstArray =
         (SCMBKeyBindingValue*)&inst.base[inst.hdr->keyBindingArray.start];          (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
  
     Uint32 numberKeyBindings = inst.hdr->numberKeyBindings;     Uint32 numberKeyBindings = inst.hdr->numberKeyBindings;
  
Line 1365 
Line 1678 
                 0,                 0,
                 scmoInstArray[i].data,                 scmoInstArray[i].data,
                 inst.base);                 inst.base);
             newObjectPath._rep->_keyBindings.append(              keys.append(
                 CIMKeyBinding(                 CIMKeyBinding(
                     CIMNameCast(NEWCIMSTR(scmoClassArray[i].name,clsbase)),                      CIMNameCast(_newCimString(scmoClassArray[i].name,clsbase)),
                     theKeyBindingValue                     theKeyBindingValue
                     ));                     ));
         }         }
     }     }
  
     newObjectPath._rep->_host = NEWCIMSTR(inst.hdr->hostName,inst.base);      // Are there user defined key bindings ?
     newObjectPath._rep->_nameSpace =      if (0 != inst.hdr->numberUserKeyBindings)
         CIMNamespaceNameCast(NEWCIMSTR(clshdr->nameSpace,clsbase));      {
     newObjectPath._rep->_className=          SCMBUserKeyBindingElement* theUserDefKBElement =
         CIMNameCast(NEWCIMSTR(clshdr->className,clsbase));              (SCMBUserKeyBindingElement*)
                    &(inst.base[inst.hdr->userKeyBindingElement.start]);
   
           for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindings; i++)
           {
               if (theUserDefKBElement->value.isSet)
               {
                   _getCIMValueFromSCMBUnion(
                       theKeyBindingValue,
                       theUserDefKBElement->type,
                       false, // can never be a null value
                       false, // can never be an array
                       0,
                       theUserDefKBElement->value.data,
                       inst.base);
   
                   keys.append(
                       CIMKeyBinding(
                           CIMNameCast(
                               _newCimString(theUserDefKBElement->name,inst.base)),
                       theKeyBindingValue));
               }
               theUserDefKBElement =
                   (SCMBUserKeyBindingElement*)
                        &(inst.base[theUserDefKBElement->nextElement.start]);
           } // for all user def. key bindings.
       }
   
       String host = _newCimString(inst.hdr->hostName,inst.base);
   
       // Use name space and class name of the instance
       CIMNamespaceName nameSpace =
           CIMNamespaceNameCast(_newCimString(inst.hdr->instNameSpace,inst.base));
  
     cimObj = newObjectPath;      CIMName className =
           CIMNameCast(_newCimString(inst.hdr->instClassName,inst.base));
   
       cimObj.set(host,nameSpace,className,keys);
 } }
  
 CIMProperty SCMOInstance::_getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const CIMProperty SCMOInstance::_getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const
Line 1388 
Line 1736 
     CIMProperty retProperty;     CIMProperty retProperty;
  
     // For better usability define pointers to SCMO Class data structures.     // For better usability define pointers to SCMO Class data structures.
     SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr;      SCMBClass_Main* clshdr = inst.hdr->theClass.ptr->cls.hdr;
     char* clsbase = inst.hdr->theClass->cls.base;      char* clsbase = inst.hdr->theClass.ptr->cls.base;
  
  
     SCMBClassPropertyNode& clsProp =     SCMBClassPropertyNode& clsProp =
Line 1399 
Line 1747 
     SCMBValue& instValue =     SCMBValue& instValue =
         ((SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]))[nodeIdx];         ((SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]))[nodeIdx];
  
       if (instValue.flags.isSet)
       {
     _getCIMValueFromSCMBValue(theValue,instValue,inst.base);     _getCIMValueFromSCMBValue(theValue,instValue,inst.base);
       }
       else
       {
           _getCIMValueFromSCMBValue(
               theValue,
               clsProp.theProperty.defaultValue,
               clsbase);
       }
   
  
  
     if (inst.hdr->flags.includeClassOrigin)     if (inst.hdr->flags.includeClassOrigin)
     {     {
         retProperty = CIMProperty(         retProperty = CIMProperty(
             CIMNameCast(NEWCIMSTR(clsProp.theProperty.name,clsbase)),              CIMNameCast(_newCimString(clsProp.theProperty.name,clsbase)),
             theValue,             theValue,
             theValue.getArraySize(),             theValue.getArraySize(),
             CIMNameCast(NEWCIMSTR(clsProp.theProperty.refClassName,clsbase)),              CIMNameCast(
             CIMNameCast(NEWCIMSTR(clsProp.theProperty.originClassName,clsbase)),                  _newCimString(clsProp.theProperty.refClassName,clsbase)),
               CIMNameCast(
                   _newCimString(clsProp.theProperty.originClassName,clsbase)),
             clsProp.theProperty.flags.propagated);             clsProp.theProperty.flags.propagated);
     }     }
     else     else
     {     {
          retProperty = CIMProperty(          retProperty = CIMProperty(
             CIMNameCast(NEWCIMSTR(clsProp.theProperty.name,clsbase)),              CIMNameCast(_newCimString(clsProp.theProperty.name,clsbase)),
             theValue,             theValue,
             theValue.getArraySize(),             theValue.getArraySize(),
             CIMNameCast(NEWCIMSTR(clsProp.theProperty.refClassName,clsbase)),              CIMNameCast(
                   _newCimString(clsProp.theProperty.refClassName,clsbase)),
             CIMName(),             CIMName(),
             clsProp.theProperty.flags.propagated);             clsProp.theProperty.flags.propagated);
     }     }
Line 1659 
Line 2021 
                 Array<Char16> x;                 Array<Char16> x;
                 for (Uint32 i = 0, k = arraySize; i < k ; i++)                 for (Uint32 i = 0, k = arraySize; i < k ; i++)
                 {                 {
                     x.append(pscmbArrayUn[i].simple.val.c16);                      x.append(Char16(pscmbArrayUn[i].simple.val.c16));
                 }                 }
                 cimV.set(x);                 cimV.set(x);
             }             }
             else             else
             {             {
                 cimV.set(scmbUn.simple.val.c16);                  cimV.set(Char16(scmbUn.simple.val.c16));
             }             }
             break;             break;
         }         }
Line 1697 
Line 2059 
  
                 for (Uint32 i = 0, k = arraySize; i < k ; i++)                 for (Uint32 i = 0, k = arraySize; i < k ; i++)
                 {                 {
                     x.append(NEWCIMSTR(pscmbArrayUn[i].stringValue,base));                      x.append(_newCimString(pscmbArrayUn[i].stringValue,base));
                 }                 }
                 cimV.set(x);                 cimV.set(x);
             }             }
             else             else
             {             {
                 cimV.set(NEWCIMSTR(scmbUn.stringValue,base));                  cimV.set(_newCimString(scmbUn.stringValue,base));
             }             }
             break;             break;
         }         }
Line 1767 
Line 2129 
         }         }
     case CIMTYPE_OBJECT:     case CIMTYPE_OBJECT:
         {         {
             CIMInstance theInstance;              CIMInstance cimInstance;
             CIMClass theClass;              CIMClass cimClass;
  
             if(isArray)             if(isArray)
             {             {
Line 1782 
Line 2144 
                                inst.hdr->flags.isClassOnly)                                inst.hdr->flags.isClassOnly)
                         {                         {
                             pscmbArrayUn[i].extRefPtr->                             pscmbArrayUn[i].extRefPtr->
                                 inst.hdr->theClass->getCIMClass(theClass);                                  inst.hdr->theClass.ptr->getCIMClass(cimClass);
                             x.append(CIMObject(theClass));                              x.append(CIMObject(cimClass));
                         }                         }
                         else                         else
                         {                         {
                             pscmbArrayUn[i].extRefPtr->                             pscmbArrayUn[i].extRefPtr->
                                 getCIMInstance(theInstance);                                  getCIMInstance(cimInstance);
                             x.append(CIMObject(theInstance));                              x.append(CIMObject(cimInstance));
                         }                         }
                     }                     }
                     else                     else
Line 1809 
Line 2171 
                     if(scmbUn.extRefPtr->inst.hdr->flags.isClassOnly)                     if(scmbUn.extRefPtr->inst.hdr->flags.isClassOnly)
                     {                     {
                         scmbUn.extRefPtr->                         scmbUn.extRefPtr->
                             inst.hdr->theClass->getCIMClass(theClass);                              inst.hdr->theClass.ptr->getCIMClass(cimClass);
                         cimV.set(CIMObject(theClass));                          cimV.set(CIMObject(cimClass));
                     }                     }
                     else                     else
                     {                     {
                         scmbUn.extRefPtr->getCIMInstance(theInstance);                          scmbUn.extRefPtr->getCIMInstance(cimInstance);
                         cimV.set(CIMObject(theInstance));                          cimV.set(CIMObject(cimInstance));
                     }                     }
                 }                 }
                 else                 else
Line 1890 
Line 2252 
  
 void SCMOInstance::_setCIMObjectPath(const CIMObjectPath& cimObj) void SCMOInstance::_setCIMObjectPath(const CIMObjectPath& cimObj)
 { {
     CIMObjectPathRep* objRep = cimObj._rep;      CString className = cimObj.getClassName().getString().getCString();
     SCMO_RC rc;  
   
     // For better usability define pointers to SCMO Class data structures.  
     SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr;  
     char* clsbase = inst.hdr->theClass->cls.base;  
   
     CString className = objRep->_className.getString().getCString();  
  
     // Is the instance from the same class ?     // Is the instance from the same class ?
     if (!(_equalNoCaseUTF8Strings(     if (!(_equalNoCaseUTF8Strings(
              clshdr->className,               inst.hdr->instClassName,
              clsbase,               inst.base,
              (const char*)className,              (const char*)className,
              strlen(className))))              strlen(className))))
     {     {
         throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_CLASS,         throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_CLASS,
            objRep->_className.getString());             cimObj.getClassName().getString());
     }     }
  
     //set host name     //set host name
     _setString(objRep->_host,inst.hdr->hostName,&inst.mem );      _setString(cimObj.getHost(),inst.hdr->hostName,&inst.mem );
   
     if (inst.hdr->numberKeyBindings < objRep->_keyBindings.size())  
     {  
         String message("CIMObjectPath has more keybindings "  
                        "than the associated class key properties.");  
         throw CIMException(CIM_ERR_FAILED, message);  
     }  
  
     for (Uint32 i = 0, k = objRep->_keyBindings.size(); i < k; i++)      const Array<CIMKeyBinding> & keys=cimObj.getKeyBindings();
     {      for (Uint32 i = 0, k = keys.size(); i < k; i++)
   
         rc = _setKeyBindingFromString(  
             (const char*)  
                     objRep->_keyBindings[i].getName().getString().getCString(),  
             objRep->_keyBindings[i].getValue());  
   
         if (rc != SCMO_OK)  
         {  
             switch (rc)  
             {  
             case SCMO_NOT_FOUND:  
                 {  
                     String message("CIMObjectPath key binding ");  
                     message.append(  
                         objRep->_keyBindings[i].getName().getString());  
                     message.append(" not found.");  
                     throw CIMException(CIM_ERR_FAILED, message);  
                 }  
             default:  
                 {                 {
                     String message("CIMObjectPath key binding ");          String key = keys[i].getValue();
                     message.append(          _setKeyBindingFromString(
                         objRep->_keyBindings[i].getName().getString());              (const char*) keys[i].getName().getString().getCString(),
                     message.append(" does not match class definition!");              _CIMTypeFromKeyBindingType(
                     throw CIMException(CIM_ERR_FAILED, message);                  (const char*)key.getCString(),
                 }                  keys[i].getType()),
             }              key);
         }         }
     }     }
  
 }  void SCMOInstance::_setCIMValueAtNodeIndex(
 void SCMOInstance::_setCIMValueAtNodeIndex(Uint32 node, CIMValueRep* valRep)      Uint32 node,
       CIMValueRep* valRep,
       CIMType realType)
 { {
     SCMBValue* theInstPropNodeArray =     SCMBValue* theInstPropNodeArray =
         (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];          (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
  
  
     SCMBValue& theInstProp = theInstPropNodeArray[node];     SCMBValue& theInstProp = theInstPropNodeArray[node];
  
     theInstProp.valueType=valRep->type;      theInstProp.valueType=realType;
     theInstProp.flags.isNull=valRep->isNull;     theInstProp.flags.isNull=valRep->isNull;
     theInstProp.flags.isArray=valRep->isArray;     theInstProp.flags.isArray=valRep->isArray;
     theInstProp.flags.isSet=true;     theInstProp.flags.isSet=true;
Line 1979 
Line 2310 
         _setUnionArrayValue(         _setUnionArrayValue(
             start,             start,
             &inst.mem,             &inst.mem,
             valRep->type,              realType,
             // Is set to the number of array members by the function.             // Is set to the number of array members by the function.
             theInstProp.valueArraySize,             theInstProp.valueArraySize,
               inst.hdr->instNameSpace.start,
               inst.hdr->instNameSpace.size,
             valRep->u);             valRep->u);
     }     }
     else     else
     {     {
         _setUnionValue(start,&inst.mem,valRep->type,valRep->u);          _setUnionValue(
               start,
               &inst.mem,
               realType,
               inst.hdr->instNameSpace.start,
               inst.hdr->instNameSpace.size,
               valRep->u);
     }     }
 } }
  
Line 1996 
Line 2335 
     return inst.base == theInstance.inst.base;     return inst.base == theInstance.inst.base;
 } }
  
   void SCMOInstance::setHostName(const char* hostName)
   {
       Uint32 len = 0;
   
       _copyOnWrite();
   
       if (hostName!=0)
       {
   
           len = strlen((const char*)hostName);
       }
       // copy including trailing '\0'
       _setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem);
   }
   
 const char* SCMOInstance::getHostName() const const char* SCMOInstance::getHostName() const
 { {
   return _getCharString(inst.hdr->hostName,inst.base);   return _getCharString(inst.hdr->hostName,inst.base);
 } }
  
 void SCMOInstance::buildKeyBindingsFromProperties()  const char* SCMOInstance::getHostName_l(Uint32& length) const
   {
       length = inst.hdr->hostName.size;
       if (0 == length)
       {
           return 0;
       }
       else
 { {
           length--;
       }
       return _getCharString(inst.hdr->hostName,inst.base);
   }
  
     Uint32* theClassKeyPropList =  void SCMOInstance::setClassName(const char* className)
         (Uint32*) &((inst.hdr->theClass->cls.base)  {
                           [(inst.hdr->theClass->cls.hdr->keyIndexList.start)]);      Uint32 len=0;
  
     SCMBKeyBindingValue* theKeyBindValueArray;      _copyOnWrite();
     SCMBValue* theInstPropNodeArray;  
  
     Uint32 propNode;      // flag the instance as compromized
       inst.hdr->flags.isCompromised=true;
       if (className!=0)
       {
           len = strlen((const char*)className);
       }
       // copy including trailing '\0'
       // _setBinary also sets the name to 0 if either className==0 or len+1==1
       _setBinary(className,len+1,inst.hdr->instClassName,&inst.mem);
   }
  
     for (Uint32 i = 0, k = inst.hdr->numberKeyBindings; i < k; i++)  void SCMOInstance::setClassName_l(const char* className, Uint32 len)
     {     {
         // the instance pointers has to be reinitialized each time,      _copyOnWrite();
         // because in _setKeyBindingFromSCMBUnion()  
         // a reallocation can take place.  
         theKeyBindValueArray =  
            (SCMBKeyBindingValue*)&inst.base[inst.hdr->keyBindingArray.start];  
  
         theInstPropNodeArray =      // flag the instance as compromised
       inst.hdr->flags.isCompromised=true;
       // copy including trailing '\0'
       // _setBinary also sets the name to 0 if either className==0 or len+1==1
       _setBinary(className,len+1,inst.hdr->instClassName,&inst.mem);
   }
   
   const char* SCMOInstance::getClassName() const
   {
       return _getCharString(inst.hdr->instClassName,inst.base);
   }
   
   const char* SCMOInstance::getClassName_l(Uint32 & length) const
   {
       length = inst.hdr->instClassName.size;
       if (0 == length)
       {
           return 0;
       }
       else
       {
           length--;
       }
       return _getCharString(inst.hdr->instClassName,inst.base);
   }
   
   void SCMOInstance::setNameSpace(const char* nameSpace)
   {
       Uint32 len = 0;
   
       _copyOnWrite();
   
       // flag the instance as compromized
       inst.hdr->flags.isCompromised=true;
   
       if (nameSpace!=0)
       {
   
           len = strlen((const char*)nameSpace);
       }
       // copy including trailing '\0'
       _setBinary(nameSpace,len+1,inst.hdr->instNameSpace,&inst.mem);
   }
   
   void SCMOInstance::setNameSpace_l(const char* nameSpace, Uint32 len)
   {
       // Copy on Write is only necessary if a realloc() becomes necessary
       if (inst.mem->freeBytes < ((len+8) & ~7))
       {
           _copyOnWrite();
       }
       // flag the instance as compromized
       inst.hdr->flags.isCompromised=true;
       // copy including trailing '\0'
       _setBinary(nameSpace,len+1,inst.hdr->instNameSpace,&inst.mem);
   }
   
   const char* SCMOInstance::getNameSpace() const
   {
       return _getCharString(inst.hdr->instNameSpace,inst.base);
   }
   
   const char* SCMOInstance::getNameSpace_l(Uint32 & length) const
   {
       length = inst.hdr->instNameSpace.size;
       if (0 == length)
       {
           return 0;
       }
       else
       {
           length--;
       }
       return _getCharString(inst.hdr->instNameSpace,inst.base);
   }
   
   void SCMOInstance::completeHostNameAndNamespace(
       const char* hn,
       Uint32 hnLen,
       const char* ns,
       Uint32 nsLen)
   {
       // hostName is Null or empty String ?
       if (0 == inst.hdr->hostName.size ||
           0 == inst.base[inst.hdr->hostName.start])
       {
           // Copy on Write is only necessary if a realloc() becomes necessary
           if (inst.mem->freeBytes < ((hnLen+8) & ~7))
           {
               _copyOnWrite();
           }
           // copy including trailing '\0'
           _setBinary(hn,hnLen+1,inst.hdr->hostName,&inst.mem);
       }
       // namespace is Null or empty String ?
       if (0 == inst.hdr->instNameSpace.size ||
           0 == inst.base[inst.hdr->instNameSpace.start])
       {
           setNameSpace_l(ns,nsLen);
       }
   }
   
   
   void SCMOInstance::buildKeyBindingsFromProperties()
   {
       Uint32 propNode;
       // The theClassKeyPropList pointer will always be valid,
       // even after a realloc() caused by copyOnWrite()
       // as this is an absolute pointer to the class which does not change
       Uint32* theClassKeyPropList =
           (Uint32*) &((inst.hdr->theClass.ptr->cls.base)
                       [(inst.hdr->theClass.ptr->cls.hdr->keyIndexList.start)]);
   
       SCMBKeyBindingValue* theKeyBindValueArray =
           (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
       SCMBValue* theInstPropNodeArray=
             (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];             (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];
  
       inst.hdr->numberKeyBindings =
           inst.hdr->theClass.ptr->cls.hdr->keyBindingSet.number;
   
       for (Uint32 i = 0, k = inst.hdr->numberKeyBindings; i < k; i++)
       {
         // If the keybinding is not set.         // If the keybinding is not set.
         if (!theKeyBindValueArray[i].isSet)         if (!theKeyBindValueArray[i].isSet)
         {         {
             // get the node index for this key binding form class             // get the node index for this key binding form class
             propNode = theClassKeyPropList[i];             propNode = theClassKeyPropList[i];
  
             // if property was not set by the provider or it is null.              // if property was set by the provider and it is not null.
             if (!theInstPropNodeArray[propNode].flags.isSet ||              if ( theInstPropNodeArray[propNode].flags.isSet &&
                  theInstPropNodeArray[propNode].flags.isNull)                  !theInstPropNodeArray[propNode].flags.isNull)
             {              {
                 const char * propName =                  _copyOnWrite();
                     inst.hdr->theClass->_getPropertyNameAtNode(propNode);                  // the instance pointers have to be recalculated as copyOnWrite
                 throw NoSuchProperty(String(propName));                  // might change the absolute address of these pointers
             }                  theInstPropNodeArray =
                       (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];
                   theKeyBindValueArray =
                       (SCMBKeyBindingValue*)
                           &(inst.base[inst.hdr->keyBindingArray.start]);
  
             _setKeyBindingFromSCMBUnion(             _setKeyBindingFromSCMBUnion(
                 theInstPropNodeArray[propNode].valueType,                 theInstPropNodeArray[propNode].valueType,
                 theInstPropNodeArray[propNode].value,                 theInstPropNodeArray[propNode].value,
                 inst.base,                 inst.base,
                 theKeyBindValueArray[i]);                 theKeyBindValueArray[i]);
   
                   // the instance pointers have to be reinitialized each time,
                   // because a reallocation can take place
                   // in _setKeyBindingFromSCMBUnion()
                   theKeyBindValueArray =
                       (SCMBKeyBindingValue*)
                           &(inst.base[inst.hdr->keyBindingArray.start]);
                   theInstPropNodeArray =
                       (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];
   
               }
         }         }
     }     }
 } }
Line 2068 
Line 2572 
     case CIMTYPE_REAL64:     case CIMTYPE_REAL64:
     case CIMTYPE_CHAR16:     case CIMTYPE_CHAR16:
     case CIMTYPE_BOOLEAN:     case CIMTYPE_BOOLEAN:
           {
               memcpy(&keyData.data,&u,sizeof(SCMBUnion));
               keyData.data.simple.hasValue=true;
               keyData.isSet=true;
               break;
           }
     case CIMTYPE_DATETIME:     case CIMTYPE_DATETIME:
         {         {
             memcpy(&keyData.data,&u,sizeof(SCMBUnion));             memcpy(&keyData.data,&u,sizeof(SCMBUnion));
Line 2077 
Line 2587 
     case CIMTYPE_STRING:     case CIMTYPE_STRING:
         {         {
             keyData.isSet=true;             keyData.isSet=true;
               // Check if a key binding is set with in the same instance.
               // If this is the case, a reallocation can take place and the
               // uBase pointer can be invalid and cause a read in freed memory!
               if (uBase == inst.base)
               {
                   if (0 != u.stringValue.size )
                   {
                       // We are doing a in instance copy of data.
                       // We can not use the _setBinary() function because
                       // all real pointer can be in valid after
                       // the _getFreeSprace() function!
                       // We have to save all relative pointer on the stack.
                       Uint64 start;
                       SCMBDataPtr tmp;
                       tmp.size = u.stringValue.size;
                       tmp.start = u.stringValue.start;
   
                       // In this function a reallocation may take place!
                       // The keyData.data.stringValue is set
                       // before the rallocation.
                       start = _getFreeSpace(
                           keyData.data.stringValue,
                           u.stringValue.size,
                           &inst.mem);
                       // Copy the string,
                       // but using the own base pointer and the saved relative
                       // string pointer.
                       memcpy(
                           &(inst.base[start]),
                           _getCharString(tmp,inst.base),
                           tmp.size);
                   }
                   else
                   {
                      keyData.data.stringValue.size=0;
                      keyData.data.stringValue.start=0;
                   }
   
               }
               else
               {
             _setBinary(             _setBinary(
                 &uBase[u.stringValue.start],                 &uBase[u.stringValue.start],
                 u.stringValue.length,                      u.stringValue.size,
                 keyData.data.stringValue,                 keyData.data.stringValue,
                 &inst.mem);                 &inst.mem);
               }
   
             break;             break;
         }         }
     case CIMTYPE_REFERENCE:     case CIMTYPE_REFERENCE:
Line 2094 
Line 2647 
             if(u.extRefPtr)             if(u.extRefPtr)
             {             {
                 keyData.data.extRefPtr = new SCMOInstance(*u.extRefPtr);                 keyData.data.extRefPtr = new SCMOInstance(*u.extRefPtr);
                   keyData.isSet=true;
                   // This function can cause a reallocation !
                   // Pointers can be invalid after the call.
                   _setExtRefIndex(&(keyData.data),&inst.mem);
             }             }
             else             else
             {             {
                   keyData.isSet=true;
                 keyData.data.extRefPtr=0;                 keyData.data.extRefPtr=0;
             }             }
             keyData.isSet=true;  
             break;             break;
         }         }
     case CIMTYPE_OBJECT:     case CIMTYPE_OBJECT:
Line 2117 
Line 2674 
     }     }
 } }
  
 void SCMOInstance::setHostName(const char* hostName)  
 {  
     Uint32 len;  
   
     if (hostName!=0)  
     {  
   
         len = strlen((const char*)hostName);  
         if(len != 0)  
         {  
   
             // copy including trailing '\0'  
             _setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem);  
             return;  
         }  
   
     }  
     inst.hdr->hostName.start=0;  
     inst.hdr->hostName.length=0;  
 }  
   
 const char* SCMOInstance::getClassName() const  
 {  
     return _getCharString(  
         inst.hdr->theClass->cls.hdr->className,  
         inst.hdr->theClass->cls.base);  
 }  
   
 const char* SCMOInstance::getClassName_l(Uint64 & length) const  
 {  
     SCMOClass * scmoCls = inst.hdr->theClass;  
     length = scmoCls->cls.hdr->className.length;  
     return _getCharString(  
         scmoCls->cls.hdr->className,  
         scmoCls->cls.base);  
   
 }  
   
   
 const char* SCMOInstance::getNameSpace() const  
 {  
     return _getCharString(  
         inst.hdr->theClass->cls.hdr->nameSpace,  
         inst.hdr->theClass->cls.base);  
 }  
   
 void SCMOInstance::_initSCMOInstance(SCMOClass* pClass) void SCMOInstance::_initSCMOInstance(SCMOClass* pClass)
 { {
     PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE     PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE
Line 2176 
Line 2687 
         throw PEGASUS_STD(bad_alloc)();         throw PEGASUS_STD(bad_alloc)();
     }     }
  
       memset(inst.base,0,sizeof(SCMBInstance_Main));
   
     // initalize eye catcher     // initalize eye catcher
     inst.hdr->header.magic=PEGASUS_SCMB_INSTANCE_MAGIC;     inst.hdr->header.magic=PEGASUS_SCMB_INSTANCE_MAGIC;
     inst.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE;     inst.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE;
Line 2188 
Line 2701 
     inst.hdr->refCount=1;     inst.hdr->refCount=1;
  
     //Assign the SCMBClass structure this instance based on.     //Assign the SCMBClass structure this instance based on.
     inst.hdr->theClass = pClass;      inst.hdr->theClass.ptr = pClass;
  
     // Init flags      // Copy name space name and class name of the class
     inst.hdr->flags.includeQualifiers=false;      _setBinary(
     inst.hdr->flags.includeClassOrigin=false;          _getCharString(inst.hdr->theClass.ptr->cls.hdr->className,
     inst.hdr->flags.isFiltered=false;                         inst.hdr->theClass.ptr->cls.base),
     inst.hdr->flags.isClassOnly=false;          inst.hdr->theClass.ptr->cls.hdr->className.size,
           inst.hdr->instClassName,
           &inst.mem);
  
     inst.hdr->hostName.start=0;      _setBinary(
     inst.hdr->hostName.length=0;          _getCharString(inst.hdr->theClass.ptr->cls.hdr->nameSpace,
                          inst.hdr->theClass.ptr->cls.base),
           inst.hdr->theClass.ptr->cls.hdr->nameSpace.size,
           inst.hdr->instNameSpace,
           &inst.mem);
  
     // Number of key bindings     // Number of key bindings
     inst.hdr->numberKeyBindings =     inst.hdr->numberKeyBindings =
         inst.hdr->theClass->cls.hdr->keyBindingSet.number;          inst.hdr->theClass.ptr->cls.hdr->keyBindingSet.number;
  
     // Number of properties     // Number of properties
     inst.hdr->numberProperties =     inst.hdr->numberProperties =
         inst.hdr->theClass->cls.hdr->propertySet.number;          inst.hdr->theClass.ptr->cls.hdr->propertySet.number;
  
     // Allocate the SCMOInstanceKeyBindingArray     // Allocate the SCMOInstanceKeyBindingArray
     _getFreeSpace(     _getFreeSpace(
           inst.hdr->keyBindingArray,           inst.hdr->keyBindingArray,
           sizeof(SCMBKeyBindingValue)*inst.hdr->numberKeyBindings,           sizeof(SCMBKeyBindingValue)*inst.hdr->numberKeyBindings,
           &inst.mem,            &inst.mem);
           true);  
  
     // Allocate the SCMBInstancePropertyArray     // Allocate the SCMBInstancePropertyArray
     _getFreeSpace(     _getFreeSpace(
         inst.hdr->propertyArray,         inst.hdr->propertyArray,
         sizeof(SCMBValue)*inst.hdr->numberProperties,         sizeof(SCMBValue)*inst.hdr->numberProperties,
         &inst.mem,          &inst.mem);
         true);  
   
     inst.hdr->propertyFilter.start=0;  
     inst.hdr->propertyFilter.length=0;  
     inst.hdr->propertyFilterIndexMap.start=0;  
     inst.hdr->propertyFilterIndexMap.length=0;  
   
  
 } }
  
Line 2233 
Line 2744 
 { {
     CIMPropertyRep* propRep;     CIMPropertyRep* propRep;
     Uint32 propNode;     Uint32 propNode;
     Uint64 valueStart;  
     SCMO_RC rc;     SCMO_RC rc;
       CIMType realType;
  
     CIMInstanceRep* instRep = cimInstance._rep;     CIMInstanceRep* instRep = cimInstance._rep;
  
Line 2242 
Line 2753 
     // The instance level qualifiers are stored on the associated SCMOClass.     // The instance level qualifiers are stored on the associated SCMOClass.
     inst.hdr->flags.includeQualifiers=(instRep->_qualifiers.getCount()>0);     inst.hdr->flags.includeQualifiers=(instRep->_qualifiers.getCount()>0);
  
       // To ensure that at converting a CIMInstance to a SCMOInstance
       // and vice versa do have the same property set.
       inst.hdr->flags.exportSetOnly=true;
   
     _setCIMObjectPath(instRep->_reference);     _setCIMObjectPath(instRep->_reference);
  
     // Copy all properties     // Copy all properties
Line 2264 
Line 2779 
         }         }
  
         // get the property node index for the property         // get the property node index for the property
         rc = inst.hdr->theClass->_getProperyNodeIndex(          rc = inst.hdr->theClass.ptr->_getProperyNodeIndex(
             propNode,             propNode,
             (const char*)propRep->_name.getString().getCString());             (const char*)propRep->_name.getString().getCString());
  
         if (rc != SCMO_OK)          if (rc == SCMO_OK)
         {         {
             throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NO_SUCH_PROPERTY,              // The type stored in the class information is set on realType.
                propRep->_name.getString());              // It must be used in further calls to guaranty consistence.
         }              rc = inst.hdr->theClass.ptr->_isNodeSameType(
         rc = inst.hdr->theClass->_isNodeSameType(  
                  propNode,                  propNode,
                  propRep->_value._rep->type,                  propRep->_value._rep->type,
                  propRep->_value._rep->isArray);                       propRep->_value._rep->isArray,
                        realType);
         if (rc == SCMO_OK)         if (rc == SCMO_OK)
         {         {
             _setCIMValueAtNodeIndex(propNode, propRep->_value._rep);                  _setCIMValueAtNodeIndex(
                       propNode,
                       propRep->_value._rep,
                       realType);
         }         }
         else         else
         {         {
             throw PEGASUS_CIM_EXCEPTION(CIM_ERR_TYPE_MISMATCH,                  PEG_TRACE((TRC_DISCARDED_DATA,Tracer::LEVEL2,
                propRep->_name.getString());                      "CIMProperty '%s' with type '%s' "
                           "can not be set at SCMOInstance."
                           "It is has not same type '%s' as defined in "
                           "class '%s' of name space '%s'",
                        cimTypeToString(propRep->_value._rep->type),
                       (const char*)propRep->_name.getString().getCString(),
                        cimTypeToString(realType),
                       (const char*)instRep->_reference._rep->
                              _className.getString().getCString(),
                       (const char*)instRep->_reference._rep->
                              _nameSpace.getString().getCString()));
               }
   
           }
           else
           {
   
               PEG_TRACE((TRC_DISCARDED_DATA,Tracer::LEVEL2,
                   "CIMProperty '%s' can not be set at SCMOInstance."
                       "It is not part of class '%s' of name space '%s'",
                   (const char*)propRep->_name.getString().getCString(),
                   (const char*)instRep->_reference._rep->
                          _className.getString().getCString(),
                   (const char*)instRep->_reference._rep->
                          _nameSpace.getString().getCString()));
         }         }
     }     }
 } }
Line 2304 
Line 2846 
     isArray = false;     isArray = false;
     size = 0;     size = 0;
  
     rc = inst.hdr->theClass->_getProperyNodeIndex(node,name);      rc = inst.hdr->theClass.ptr->_getProperyNodeIndex(node,name);
     if (rc != SCMO_OK)     if (rc != SCMO_OK)
     {     {
         return rc;         return rc;
     }     }
  
     // is filtering on ?  
     if (inst.hdr->flags.isFiltered)  
     {  
         // Is the property NOT in the property filter ?  
         if(!_isPropertyInFilter(node))  
         {  
             // The named propery is not part of this instance  
             // due to filtering.  
             return SCMO_NOT_FOUND;  
         }  
     }  
   
     return  _getPropertyAtNodeIndex(node,&pname,type,pOutVal,isArray,size);     return  _getPropertyAtNodeIndex(node,&pname,type,pOutVal,isArray,size);
 } }
  
Line 2337 
Line 2867 
     *pOutVal = 0;     *pOutVal = 0;
     isArray = false;     isArray = false;
     size = 0;     size = 0;
     Uint32 node;  
   
     // is filtering on ?  
     if (inst.hdr->flags.isFiltered)  
     {  
         // check the number of properties part of the filter  
         if (idx >= inst.hdr->filterProperties)  
         {  
             return SCMO_INDEX_OUT_OF_BOUND;  
         }  
   
         // Get absolut pointer to property filter index map of the instance  
         Uint32* propertyFilterIndexMap =  
         (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);  
   
         // get the real node index of the property.  
         node = propertyFilterIndexMap[idx];  
     }  
     else  
     {  
         // the index is used as node index.  
         node = idx;  
         if (node >= inst.hdr->numberProperties)  
         {  
             return SCMO_INDEX_OUT_OF_BOUND;  
         }  
     }  
   
     return  _getPropertyAtNodeIndex(node,pname,type,pOutVal,isArray,size);  
 }  
   
 SCMO_RC SCMOInstance::getPropertyAt(  
     Uint32 pos,  
     SCMBValue** value,  
     const char ** valueBase,  
     SCMBClassProperty ** propDef) const  
 {  
     Uint32 node;  
     // is filtering on ?  
     if (inst.hdr->flags.isFiltered)  
     {  
         // check the number of properties part of the filter  
         if (pos >= inst.hdr->filterProperties)  
         {  
             return SCMO_INDEX_OUT_OF_BOUND;  
         }  
  
         // Get absolut pointer to property filter index map of the instance      if (idx >= inst.hdr->numberProperties)
         Uint32* propertyFilterIndexMap =  
         (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);  
   
         // get the real node index of the property.  
         node = propertyFilterIndexMap[pos];  
     }  
     else  
     {  
         // the index is used as node index.  
         node = pos;  
         if (node >= inst.hdr->numberProperties)  
         {         {
             return SCMO_INDEX_OUT_OF_BOUND;             return SCMO_INDEX_OUT_OF_BOUND;
         }         }
     }  
   
     SCMBValue* theInstPropNodeArray =  
         (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];  
   
     // create a pointer to property node array of the class.  
     Uint64 idx = inst.hdr->theClass->cls.hdr->propertySet.nodeArray.start;  
     SCMBClassPropertyNode* theClassPropNodeArray =  
         (SCMBClassPropertyNode*)&(inst.hdr->theClass->cls.base)[idx];  
   
     // return the absolute pointer to the property definition  
     *propDef= &(theClassPropNodeArray[node].theProperty);  
   
     // need check if property set or not, if not set use the default value  
     if (theInstPropNodeArray[node].flags.isSet)  
     {  
         // return the absolute pointer to the property value in the instance  
         *value = &(theInstPropNodeArray[node]);  
         *valueBase = inst.base;  
     }  
     else  
     {  
         // return the absolute pointer to  
         *value = &(theClassPropNodeArray[node].theProperty.defaultValue);  
         *valueBase = inst.hdr->theClass->cls.base;  
     }  
  
     return SCMO_OK;      return  _getPropertyAtNodeIndex(idx,pname,type,pOutVal,isArray,size);
 } }
  
   
 SCMO_RC SCMOInstance::getPropertyNodeIndex(const char* name, Uint32& node) const SCMO_RC SCMOInstance::getPropertyNodeIndex(const char* name, Uint32& node) const
 { {
     SCMO_RC rc;     SCMO_RC rc;
Line 2438 
Line 2884 
         return SCMO_INVALID_PARAMETER;         return SCMO_INVALID_PARAMETER;
     }     }
  
     rc = inst.hdr->theClass->_getProperyNodeIndex(node,name);      rc = inst.hdr->theClass.ptr->_getProperyNodeIndex(node,name);
  
     return rc;     return rc;
  
Line 2452 
Line 2898 
     Uint32 size,     Uint32 size,
     const char* origin)     const char* origin)
 { {
       // In this function no  _copyOnWrite(), it does not change the instance.
   
     Uint32 node;     Uint32 node;
     SCMO_RC rc;     SCMO_RC rc;
       CIMType realType;
  
     rc = inst.hdr->theClass->_getProperyNodeIndex(node,name);      rc = inst.hdr->theClass.ptr->_getProperyNodeIndex(node,name);
     if (rc != SCMO_OK)     if (rc != SCMO_OK)
     {     {
         return rc;         return rc;
     }     }
  
     // Is the traget type OK ?     // Is the traget type OK ?
     rc = inst.hdr->theClass->_isNodeSameType(node,type,isArray);      // The type stored in the class information is set on realType.
       // It must be used in further calls to guaranty consistence.
       rc = inst.hdr->theClass.ptr->_isNodeSameType(node,type,isArray,realType);
     if (rc != SCMO_OK)     if (rc != SCMO_OK)
     {     {
         return rc;         return rc;
     }     }
  
     // is filtering on ?  
     if (inst.hdr->flags.isFiltered)  
     {  
         // Is the property NOT in the property filter ?  
         if(!_isPropertyInFilter(node))  
         {  
             // The named propery is not part of this instance  
             // due to filtering.  
             return SCMO_NOT_FOUND;  
         }  
     }  
   
     // check class origin if set.     // check class origin if set.
     if (origin!= 0)     if (origin!= 0)
     {     {
         if(!inst.hdr->theClass->_isSamePropOrigin(node,origin))          if(!inst.hdr->theClass.ptr->_isSamePropOrigin(node,origin))
         {         {
             return SCMO_NOT_SAME_ORIGIN;             return SCMO_NOT_SAME_ORIGIN;
         }         }
     }     }
  
  
     _setPropertyAtNodeIndex(node,type,pInVal,isArray,size);      _setPropertyAtNodeIndex(node,realType,pInVal,isArray,size);
  
     return SCMO_OK;     return SCMO_OK;
 } }
Line 2502 
Line 2941 
      Boolean isArray,      Boolean isArray,
      Uint32 size)      Uint32 size)
  {  {
       // In this function no  _copyOnWrite(), it does not change the instance.
   
      SCMO_RC rc;      SCMO_RC rc;
       CIMType realType;
  
      if (node >= inst.hdr->numberProperties)      if (node >= inst.hdr->numberProperties)
      {      {
          return SCMO_INDEX_OUT_OF_BOUND;          return SCMO_INDEX_OUT_OF_BOUND;
      }      }
  
      // is filtering on ?  
      if (inst.hdr->flags.isFiltered)  
      {  
          // Is the property NOT in the property filter ?  
          if(!_isPropertyInFilter(node))  
          {  
              // The proptery of the is not set due to filtering.  
              return SCMO_OK;  
          }  
      }  
   
      // Is the traget type OK ?      // Is the traget type OK ?
      rc = inst.hdr->theClass->_isNodeSameType(node,type,isArray);      // The type stored in the class information is set on realType.
       // It must be used in further calls to guaranty consistence.
       rc = inst.hdr->theClass.ptr->_isNodeSameType(node,type,isArray,realType);
      if (rc != SCMO_OK)      if (rc != SCMO_OK)
      {      {
          return rc;          return rc;
      }      }
  
      _setPropertyAtNodeIndex(node,type,pInVal,isArray,size);      _setPropertyAtNodeIndex(node,realType,pInVal,isArray,size);
  
      return SCMO_OK;      return SCMO_OK;
  }  }
Line 2539 
Line 2972 
     Boolean isArray,     Boolean isArray,
     Uint32 size)     Uint32 size)
 { {
   
       _copyOnWrite();
   
     SCMBValue* theInstPropNodeArray =     SCMBValue* theInstPropNodeArray =
         (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];          (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
  
  
     theInstPropNodeArray[node].flags.isSet=true;     theInstPropNodeArray[node].flags.isSet=true;
Line 2557 
Line 2993 
     }     }
     else     else
     {     {
           theInstPropNodeArray[node].flags.isNull=false;
         _setSCMBUnion(         _setSCMBUnion(
             pInVal,             pInVal,
             type,             type,
Line 2588 
Line 3025 
     case CIMTYPE_REAL32:     case CIMTYPE_REAL32:
     case CIMTYPE_REAL64:     case CIMTYPE_REAL64:
     case CIMTYPE_CHAR16:     case CIMTYPE_CHAR16:
           {
               if (isArray)
               {
                   _setBinary(pInVal,size*sizeof(SCMBUnion),
                              u.arrayValue,
                              &inst.mem );
               }
               else
               {
                   memcpy(&u,pInVal,sizeof(SCMBUnion));
                   u.simple.hasValue=true;
               }
               break;
           }
     case CIMTYPE_DATETIME:     case CIMTYPE_DATETIME:
         {         {
             if (isArray)             if (isArray)
Line 2599 
Line 3050 
             else             else
             {             {
                 memcpy(&u,pInVal,sizeof(SCMBUnion));                 memcpy(&u,pInVal,sizeof(SCMBUnion));
   
             }             }
             break;             break;
         }         }
Line 2612 
Line 3064 
                 startPtr = _getFreeSpace(                 startPtr = _getFreeSpace(
                     u.arrayValue,                     u.arrayValue,
                     size*sizeof(SCMBUnion),                     size*sizeof(SCMBUnion),
                     &inst.mem,true);                      &inst.mem);
  
                 for (Uint32 i = 0; i < size; i++)                 for (Uint32 i = 0; i < size; i++)
                 {                 {
Line 2653 
Line 3105 
                 startPtr = _getFreeSpace(                 startPtr = _getFreeSpace(
                     u.arrayValue,                     u.arrayValue,
                     size*sizeof(SCMBUnion),                     size*sizeof(SCMBUnion),
                     &inst.mem,false);                      &inst.mem);
  
                 ptr = (SCMBUnion*)&(inst.base[startPtr]);                 ptr = (SCMBUnion*)&(inst.base[startPtr]);
  
Line 2663 
Line 3115 
                     {                     {
                         ptr[i].extRefPtr=                         ptr[i].extRefPtr=
                             new SCMOInstance(*(pInVal[i].extRefPtr));                             new SCMOInstance(*(pInVal[i].extRefPtr));
   
                           // This function can cause a reallocation !
                           // Pointers can be invalid after the call.
                           _setExtRefIndex(&(ptr[i]),&inst.mem);
                     }                     }
                     else                     else
                     {                     {
Line 2681 
Line 3137 
                 if(pInVal->extRefPtr)                 if(pInVal->extRefPtr)
                 {                 {
                     u.extRefPtr = new SCMOInstance(*(pInVal->extRefPtr));                     u.extRefPtr = new SCMOInstance(*(pInVal->extRefPtr));
                       // This function can cause a reallocation !
                       // Pointers can be invalid after the call.
                       _setExtRefIndex(&u,&inst.mem);
   
                 }                 }
                 else                 else
                 {                 {
Line 2702 
Line 3162 
     SCMBMgmt_Header** pmem,     SCMBMgmt_Header** pmem,
     CIMType type,     CIMType type,
     Uint32& n,     Uint32& n,
       Uint64 startNS,
       Uint32 sizeNS,
     Union& u)     Union& u)
 { {
     SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]);     SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]);
Line 2719 
Line 3181 
             arrayStart = _getFreeSpace(             arrayStart = _getFreeSpace(
                 scmoUnion->arrayValue,                 scmoUnion->arrayValue,
                 loop*sizeof(SCMBUnion),                 loop*sizeof(SCMBUnion),
                 pmem,                  pmem);
                 true);  
  
             ConstArrayIterator<Boolean> iterator(*x);             ConstArrayIterator<Boolean> iterator(*x);
  
Line 2741 
Line 3202 
             arrayStart = _getFreeSpace(             arrayStart = _getFreeSpace(
                 scmoUnion->arrayValue,                 scmoUnion->arrayValue,
                 loop*sizeof(SCMBUnion),                 loop*sizeof(SCMBUnion),
                 pmem,                  pmem);
                 true);  
  
             ConstArrayIterator<Uint8> iterator(*x);             ConstArrayIterator<Uint8> iterator(*x);
  
Line 2763 
Line 3223 
             arrayStart = _getFreeSpace(             arrayStart = _getFreeSpace(
                 scmoUnion->arrayValue,                 scmoUnion->arrayValue,
                 loop*sizeof(SCMBUnion),                 loop*sizeof(SCMBUnion),
                 pmem,                  pmem);
                 true);  
  
             ConstArrayIterator<Sint8> iterator(*x);             ConstArrayIterator<Sint8> iterator(*x);
  
Line 2785 
Line 3244 
             arrayStart = _getFreeSpace(             arrayStart = _getFreeSpace(
                 scmoUnion->arrayValue,                 scmoUnion->arrayValue,
                 loop*sizeof(SCMBUnion),                 loop*sizeof(SCMBUnion),
                 pmem,                  pmem);
                 true);  
  
             ConstArrayIterator<Uint16> iterator(*x);             ConstArrayIterator<Uint16> iterator(*x);
  
Line 2807 
Line 3265 
             arrayStart = _getFreeSpace(             arrayStart = _getFreeSpace(
                 scmoUnion->arrayValue,                 scmoUnion->arrayValue,
                 loop*sizeof(SCMBUnion),                 loop*sizeof(SCMBUnion),
                 pmem,                  pmem);
                 true);  
  
             ConstArrayIterator<Sint16> iterator(*x);             ConstArrayIterator<Sint16> iterator(*x);
  
Line 2829 
Line 3286 
             arrayStart = _getFreeSpace(             arrayStart = _getFreeSpace(
                 scmoUnion->arrayValue,                 scmoUnion->arrayValue,
                 loop*sizeof(SCMBUnion),                 loop*sizeof(SCMBUnion),
                 pmem,                  pmem);
                 true);  
  
             ConstArrayIterator<Uint32> iterator(*x);             ConstArrayIterator<Uint32> iterator(*x);
  
Line 2851 
Line 3307 
             arrayStart = _getFreeSpace(             arrayStart = _getFreeSpace(
                 scmoUnion->arrayValue,                 scmoUnion->arrayValue,
                 loop*sizeof(SCMBUnion),                 loop*sizeof(SCMBUnion),
                 pmem,                  pmem);
                 true);  
  
             ConstArrayIterator<Sint32> iterator(*x);             ConstArrayIterator<Sint32> iterator(*x);
  
Line 2873 
Line 3328 
             arrayStart = _getFreeSpace(             arrayStart = _getFreeSpace(
                 scmoUnion->arrayValue,                 scmoUnion->arrayValue,
                 loop*sizeof(SCMBUnion),                 loop*sizeof(SCMBUnion),
                 pmem,                  pmem);
                 true);  
  
             ConstArrayIterator<Uint64> iterator(*x);             ConstArrayIterator<Uint64> iterator(*x);
  
Line 2895 
Line 3349 
             arrayStart = _getFreeSpace(             arrayStart = _getFreeSpace(
                 scmoUnion->arrayValue,                 scmoUnion->arrayValue,
                 loop*sizeof(SCMBUnion),                 loop*sizeof(SCMBUnion),
                 pmem,                  pmem);
                 true);  
  
             ConstArrayIterator<Sint64> iterator(*x);             ConstArrayIterator<Sint64> iterator(*x);
  
Line 2917 
Line 3370 
             arrayStart = _getFreeSpace(             arrayStart = _getFreeSpace(
                 scmoUnion->arrayValue,                 scmoUnion->arrayValue,
                 loop*sizeof(SCMBUnion),                 loop*sizeof(SCMBUnion),
                 pmem,                  pmem);
                 true);  
  
             ConstArrayIterator<Real32> iterator(*x);             ConstArrayIterator<Real32> iterator(*x);
  
Line 2939 
Line 3391 
             arrayStart = _getFreeSpace(             arrayStart = _getFreeSpace(
                 scmoUnion->arrayValue,                 scmoUnion->arrayValue,
                 loop*sizeof(SCMBUnion),                 loop*sizeof(SCMBUnion),
                 pmem,                  pmem);
                 true);  
  
             ConstArrayIterator<Real64> iterator(*x);             ConstArrayIterator<Real64> iterator(*x);
  
Line 2961 
Line 3412 
             arrayStart = _getFreeSpace(             arrayStart = _getFreeSpace(
                 scmoUnion->arrayValue,                 scmoUnion->arrayValue,
                 loop*sizeof(SCMBUnion),                 loop*sizeof(SCMBUnion),
                 pmem,                  pmem);
                 true);  
  
             ConstArrayIterator<Char16> iterator(*x);             ConstArrayIterator<Char16> iterator(*x);
  
Line 3044 
Line 3494 
  
             ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);             ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
  
             SCMOClass* theRefClass;  
   
             for (Uint32 i = 0; i < loop ; i++)             for (Uint32 i = 0; i < loop ; i++)
             {             {
  
                 theRefClass = _getSCMOClass(iterator[i]);  
   
                 if (theRefClass != 0)  
                 {  
                     ptargetUnion[i].extRefPtr =                     ptargetUnion[i].extRefPtr =
                         new SCMOInstance(*theRefClass,iterator[i]);                      new SCMOInstance(
                 } else                          iterator[i],
                           &(((const char*)*pmem)[startNS]),
                           sizeNS-1);
                   // Was the conversion successful?
                   if (ptargetUnion[i].extRefPtr->isEmpty())
                 {                 {
                     //There is no reference class for the object path                      // N0, delete the SCMOInstance.
                       delete ptargetUnion[i].extRefPtr;
                     ptargetUnion[i].extRefPtr = 0;                     ptargetUnion[i].extRefPtr = 0;
                 }                 }
                   else
                   {
                       _setExtRefIndex(&(ptargetUnion[i]),pmem);
                   }
             }             }
  
             break;             break;
Line 3084 
Line 3537 
  
             ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);             ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
  
             SCMOClass* theRefClass;  
   
             for (Uint32 i = 0; i < loop ; i++)             for (Uint32 i = 0; i < loop ; i++)
             {             {
                 if (iterator[i].isUninitialized())                 if (iterator[i].isUninitialized())
Line 3097 
Line 3548 
                 {                 {
                     if (iterator[i].isClass())                     if (iterator[i].isClass())
                     {                     {
                         CIMClass theClass(iterator[i]);                          CIMClass cimClass(iterator[i]);
                         ptargetUnion[i].extRefPtr = new SCMOInstance(theClass);  
                           ptargetUnion[i].extRefPtr =
                               new SCMOInstance(
                                   cimClass,
                                   (&((const char*)*pmem)[startNS]));
                         // marke as class only !                         // marke as class only !
                         ptargetUnion[i].extRefPtr->                         ptargetUnion[i].extRefPtr->
                             inst.hdr->flags.isClassOnly=true;                             inst.hdr->flags.isClassOnly=true;
   
                           // This function can cause a reallocation !
                           // Pointers can be invalid after the call.
                           _setExtRefIndex(&(ptargetUnion[i]),pmem);
                     }                     }
                     else                     else
                     {                     {
                         CIMInstance theInst(iterator[i]);                         CIMInstance theInst(iterator[i]);
                         theRefClass = _getSCMOClass(theInst.getPath());  
  
                         if (theRefClass != 0)  
                         {  
                             ptargetUnion[i].extRefPtr =                             ptargetUnion[i].extRefPtr =
                                 new SCMOInstance(*theRefClass,theInst);                              new SCMOInstance(
                         } else                                  theInst,
                                   &(((const char*)*pmem)[startNS]),
                                   sizeNS-1);
                            // Was the conversion successful?
                            if (ptargetUnion[i].extRefPtr->isEmpty())
                         {                         {
                             //There is no reference class for the object path                               // N0, delete the SCMOInstance.
                                delete ptargetUnion[i].extRefPtr;
                             ptargetUnion[i].extRefPtr = 0;                             ptargetUnion[i].extRefPtr = 0;
                         }                         }
                            else
                            {
                                // This function can cause a reallocation !
                                // Pointers can be invalid after the call.
                                _setExtRefIndex(&(ptargetUnion[i]),pmem);
                            }
                     }                     }
                 }                 }
             }             }
Line 3144 
Line 3610 
  
             ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);             ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
  
             SCMOClass* theRefClass;  
   
             for (Uint32 i = 0; i < loop ; i++)             for (Uint32 i = 0; i < loop ; i++)
             {             {
                 if (iterator[i].isUninitialized())                 if (iterator[i].isUninitialized())
Line 3155 
Line 3619 
                 }                 }
                 else                 else
                 {                 {
                     theRefClass = _getSCMOClass(iterator[i].getPath());  
   
                     if (theRefClass != 0)  
                     {  
                         ptargetUnion[i].extRefPtr =                         ptargetUnion[i].extRefPtr =
                             new SCMOInstance(*theRefClass,iterator[i]);                          new SCMOInstance(
                     } else                              iterator[i],
                               &(((const char*)*pmem)[startNS]),
                               sizeNS-1);
                       // Was the conversion successful?
                       if (ptargetUnion[i].extRefPtr->isEmpty())
                     {                     {
                         //There is no reference class for the object path                          // N0, delete the SCMOInstance.
                           delete ptargetUnion[i].extRefPtr;
                         ptargetUnion[i].extRefPtr = 0;                         ptargetUnion[i].extRefPtr = 0;
                     }                     }
                       else
                       {
                           // This function can cause a reallocation !
                           // Pointers can be invalid after the call.
                           _setExtRefIndex(&(ptargetUnion[i]),pmem);
                       }
   
                 }                 }
             }             }
  
Line 3184 
Line 3656 
     Uint64 start,     Uint64 start,
     SCMBMgmt_Header** pmem,     SCMBMgmt_Header** pmem,
     CIMType type,     CIMType type,
       Uint64 startNS,
       Uint32 sizeNS,
     Union& u)     Union& u)
 { {
     SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]);     SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]);
Line 3276 
Line 3750 
  
     case CIMTYPE_STRING:     case CIMTYPE_STRING:
         {         {
             _setString(*((String*)((void*)&u)),              CString cstr = ((String*)((void*)&u))->getCString();
               const char *cptr = (const char*)cstr;
               _setBinary(
                   cptr,
                   strlen(cptr) + 1,
                        scmoUnion->stringValue,                        scmoUnion->stringValue,
                        pmem );                        pmem );
             break;             break;
Line 3308 
Line 3786 
             CIMObjectPath* theCIMObj =             CIMObjectPath* theCIMObj =
                 (CIMObjectPath*)((void*)&u._referenceValue);                 (CIMObjectPath*)((void*)&u._referenceValue);
  
             SCMOClass* theRefClass = _getSCMOClass(*theCIMObj);  
             if (theRefClass != 0)  
             {  
                 scmoUnion->extRefPtr =                 scmoUnion->extRefPtr =
                     new SCMOInstance(*theRefClass,*theCIMObj);                  new SCMOInstance(
             } else                      *theCIMObj,
                       &(((const char*)*pmem)[startNS]),
                       sizeNS-1);
   
               // Was the conversion successful?
               if (scmoUnion->extRefPtr->isEmpty())
             {             {
                 //There is no reference class for the object path                  // N0, delete the SCMOInstance.
                   delete scmoUnion->extRefPtr;
                 scmoUnion->extRefPtr = 0;                 scmoUnion->extRefPtr = 0;
             }             }
               else
               {
                   // This function can cause a reallocation !
                   // Pointers can be invalid after the call.
                   _setExtRefIndex(scmoUnion,pmem);
               }
   
             break;             break;
         }         }
     case CIMTYPE_OBJECT:     case CIMTYPE_OBJECT:
Line 3335 
Line 3823 
             }             }
  
             CIMObject* theCIMObject =(CIMObject*)((void*)&u._objectValue);             CIMObject* theCIMObject =(CIMObject*)((void*)&u._objectValue);
             SCMOClass* theRefClass;  
  
             if (theCIMObject->isUninitialized())             if (theCIMObject->isUninitialized())
             {             {
Line 3346 
Line 3833 
             {             {
                 if (theCIMObject->isClass())                 if (theCIMObject->isClass())
                 {                 {
                     CIMClass theClass(*theCIMObject);                      CIMClass cimClass(*theCIMObject);
                     scmoUnion->extRefPtr = new SCMOInstance(theClass);  
                       scmoUnion->extRefPtr =
                           new SCMOInstance(
                               cimClass,
                               (&((const char*)*pmem)[startNS]));
                     // marke as class only !                     // marke as class only !
                     scmoUnion->extRefPtr->inst.hdr->flags.isClassOnly=true;                     scmoUnion->extRefPtr->inst.hdr->flags.isClassOnly=true;
   
                       // This function can cause a reallocation !
                       // Pointers can be invalid after the call.
                       _setExtRefIndex(scmoUnion,pmem);
                 }                 }
                 else                 else
                 {                 {
                     CIMInstance theInst(*theCIMObject);                      CIMInstance theCIMInst(*theCIMObject);
                     theRefClass = _getSCMOClass(theInst.getPath());  
  
                     if (theRefClass != 0)  
                     {  
                         scmoUnion->extRefPtr =                         scmoUnion->extRefPtr =
                             new SCMOInstance(*theRefClass,theInst);                          new SCMOInstance(
                     } else                              theCIMInst,
                               &(((const char*)*pmem)[startNS]),
                               sizeNS-1);
   
                        // Was the conversion successful?
                        if (scmoUnion->extRefPtr->isEmpty())
                     {                     {
                         //There is no reference class for the object path                           // N0, delete the SCMOInstance.
                            delete scmoUnion->extRefPtr;
                         scmoUnion->extRefPtr = 0;                         scmoUnion->extRefPtr = 0;
                     }                     }
                        else
                        {
                            // This function can cause a reallocation !
                            // Pointers can be invalid after the call.
                            _setExtRefIndex(scmoUnion,pmem);
                        }
                 }                 }
             }             }
             break;             break;
Line 3394 
Line 3897 
             }             }
             else             else
             {             {
                 SCMOClass* theRefClass = _getSCMOClass(theCIMInst->getPath());  
                 if (theRefClass != 0)  
                 {  
                     scmoUnion->extRefPtr =                     scmoUnion->extRefPtr =
                         new SCMOInstance(*theRefClass,*theCIMInst);                      new SCMOInstance(
                 } else                          *theCIMInst,
                           &(((const char*)*pmem)[startNS]),
                           sizeNS-1);
   
                    // Was the conversion successful?
                    if (scmoUnion->extRefPtr->isEmpty())
                 {                 {
                     //There is no reference class for the object path                       // N0, delete the SCMOInstance.
                        delete scmoUnion->extRefPtr;
                     scmoUnion->extRefPtr = 0;                     scmoUnion->extRefPtr = 0;
                 }                 }
                    else
                    {
                        // This function can cause a reallocation !
                        // Pointers can be invalid after the call.
                        _setExtRefIndex(scmoUnion,pmem);
                    }
             }             }
             break;             break;
         }         }
Line 3427 
Line 3939 
         (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];         (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];
  
     // create a pointer to property node array of the class.     // create a pointer to property node array of the class.
     Uint64 idx = inst.hdr->theClass->cls.hdr->propertySet.nodeArray.start;      Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->propertySet.nodeArray.start;
     SCMBClassPropertyNode* theClassPropNodeArray =     SCMBClassPropertyNode* theClassPropNodeArray =
         (SCMBClassPropertyNode*)&(inst.hdr->theClass->cls.base)[idx];          (SCMBClassPropertyNode*)&(inst.hdr->theClass.ptr->cls.base)[idx];
  
     // the property name is always from the class.     // the property name is always from the class.
     // return the absolut pointer to the property name,     // return the absolut pointer to the property name,
     // the caller has to copy the name!     // the caller has to copy the name!
     *pname=_getCharString(     *pname=_getCharString(
         theClassPropNodeArray[node].theProperty.name,         theClassPropNodeArray[node].theProperty.name,
         inst.hdr->theClass->cls.base);          inst.hdr->theClass.ptr->cls.base);
  
     // the property was set by the provider.     // the property was set by the provider.
     if (theInstPropNodeArray[node].flags.isSet)     if (theInstPropNodeArray[node].flags.isSet)
Line 3484 
Line 3996 
     Uint64 start =     Uint64 start =
         (const char*)         (const char*)
                &(theClassPropNodeArray[node].theProperty.defaultValue.value) -                &(theClassPropNodeArray[node].theProperty.defaultValue.value) -
         (inst.hdr->theClass->cls.base);          (inst.hdr->theClass.ptr->cls.base);
  
     *pvalue = _resolveSCMBUnion(     *pvalue = _resolveSCMBUnion(
         type,         type,
         isArray,         isArray,
         size,         size,
         start,         start,
         (inst.hdr->theClass->cls.base)          (inst.hdr->theClass.ptr->cls.base)
         );         );
  
     return SCMO_OK;     return SCMO_OK;
Line 3503 
Line 4015 
     if (objectPathOnly)     if (objectPathOnly)
     {     {
         // Create a new, empty SCMOInstance         // Create a new, empty SCMOInstance
         SCMOInstance newInst(*(this->inst.hdr->theClass));          SCMOInstance newInst(*(this->inst.hdr->theClass.ptr));
  
         // Copy the host name to tha new instance-         // Copy the host name to tha new instance-
         _setBinary(         _setBinary(
             _resolveDataPtr(this->inst.hdr->hostName,this->inst.base),             _resolveDataPtr(this->inst.hdr->hostName,this->inst.base),
             this->inst.hdr->hostName.length,              this->inst.hdr->hostName.size,
             newInst.inst.hdr->hostName,             newInst.inst.hdr->hostName,
             &newInst.inst.mem);             &newInst.inst.mem);
  
           newInst.inst.hdr->flags.isCompromised =
               this->inst.hdr->flags.isCompromised;
   
           // If the instance contains a user set class and/or name space name
           if (this->inst.hdr->flags.isCompromised)
           {
               // Copy the class name to tha new instance-
               _setBinary(
                   _resolveDataPtr(this->inst.hdr->instClassName,this->inst.base),
                   this->inst.hdr->instClassName.size,
                   newInst.inst.hdr->instClassName,
                   &newInst.inst.mem);
   
               // Copy the name space name to tha new instance-
               _setBinary(
                   _resolveDataPtr(this->inst.hdr->instNameSpace,this->inst.base),
                   this->inst.hdr->instNameSpace.size,
                   newInst.inst.hdr->instNameSpace,
                   &newInst.inst.mem);
           }
   
         // Copy the key bindings to that new instance.         // Copy the key bindings to that new instance.
         this->_copyKeyBindings(newInst);         this->_copyKeyBindings(newInst);
  
Line 3519 
Line 4052 
     }     }
  
     SCMOInstance newInst;     SCMOInstance newInst;
     newInst.inst.base = (char*)malloc(this->inst.mem->totalSize);      newInst.inst.base = inst.base;
     if (newInst.inst.base == 0 )      newInst._clone();
   
       return newInst;
   }
   
   void SCMOInstance::_clone()
   {
       char* newBase;
       newBase = (char*)malloc((size_t)inst.mem->totalSize);
       if (0 == newBase )
     {     {
         throw PEGASUS_STD(bad_alloc)();         throw PEGASUS_STD(bad_alloc)();
     }     }
  
     memcpy( newInst.inst.base,this->inst.base,this->inst.mem->totalSize);      memcpy( newBase,inst.base,(size_t)inst.mem->totalSize);
     // reset the refcounter of this new instance  
     newInst.inst.hdr->refCount = 1;      // make new new memory block to mine.
     // kepp the ref counter of the class correct !      inst.base = newBase;
     newInst.inst.hdr->theClass = new SCMOClass(*(this->inst.hdr->theClass));      // reset the refcounter of this instance
       inst.hdr->refCount = 1;
       // keep the ref counter of the class correct !
       inst.hdr->theClass.ptr = new SCMOClass(*(inst.hdr->theClass.ptr));
       // keep the ref count for external references
       _copyExternalReferences();
  
     return newInst;  
 } }
  
 void SCMOInstance::_copyKeyBindings(SCMOInstance& targetInst) const void SCMOInstance::_copyKeyBindings(SCMOInstance& targetInst) const
Line 3539 
Line 4085 
     Uint32 noBindings = inst.hdr->numberKeyBindings;     Uint32 noBindings = inst.hdr->numberKeyBindings;
  
     SCMBKeyBindingValue* sourceArray =     SCMBKeyBindingValue* sourceArray =
         (SCMBKeyBindingValue*)&inst.base[inst.hdr->keyBindingArray.start];          (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
  
     // Address the class keybinding information     // Address the class keybinding information
     const SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr;      const SCMBClass_Main* clshdr = inst.hdr->theClass.ptr->cls.hdr;
     const char * clsbase = inst.hdr->theClass->cls.base;      const char * clsbase = inst.hdr->theClass.ptr->cls.base;
     SCMBKeyBindingNode* scmoClassArray =     SCMBKeyBindingNode* scmoClassArray =
         (SCMBKeyBindingNode*)&clsbase[clshdr->keyBindingSet.nodeArray.start];          (SCMBKeyBindingNode*)&(clsbase[clshdr->keyBindingSet.nodeArray.start]);
  
     SCMBKeyBindingValue* targetArray;     SCMBKeyBindingValue* targetArray;
  
Line 3565 
Line 4111 
         }         }
     }     }
  
       // Are there user defined key bindings ?
       if (0 != inst.hdr->numberUserKeyBindings)
       {
           SCMBUserKeyBindingElement* theUserDefKBElement =
               (SCMBUserKeyBindingElement*)
                    &(inst.base[inst.hdr->userKeyBindingElement.start]);
   
           for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindings; i++)
           {
               if (theUserDefKBElement->value.isSet)
               {
                   targetInst._setUserDefinedKeyBinding(*theUserDefKBElement,
                                                           inst.base);
 } }
 Uint32 SCMOInstance::getPropertyCount() const  
               theUserDefKBElement =
                   (SCMBUserKeyBindingElement*)
                        &(inst.base[theUserDefKBElement->nextElement.start]);
           } // for all user def. key bindings.
       }
   }
   
   
   void SCMOInstance::_setUserDefinedKeyBinding(
           SCMBUserKeyBindingElement& theInsertElement,
           char* elementBase)
   {
   
       SCMBUserKeyBindingElement* ptrNewElement;
   
       // get an exsiting or new user defined key binding
       ptrNewElement = _getUserDefinedKeyBinding(
           _getCharString(theInsertElement.name,elementBase),
           // lenght is without the trailing '\0'
           theInsertElement.name.size-1,
           theInsertElement.type);
   
       // Copy the data
       _setKeyBindingFromSCMBUnion(
                   theInsertElement.type,
                   theInsertElement.value.data,
                   elementBase,
                   ptrNewElement->value);
   
   }
   
   
   SCMBUserKeyBindingElement* SCMOInstance::_getUserDefinedKeyBindingAt(
       Uint32 index ) const
   {
   
       // Get the start element
       SCMBUserKeyBindingElement *ptrNewElement =
           (SCMBUserKeyBindingElement*)
                &(inst.base[inst.hdr->userKeyBindingElement.start]);
   
       // calculate the index within the user defined key bindings
       index = index - inst.hdr->numberKeyBindings;
   
       // traverse trough the user defindes key binding nodes.
       for (Uint32 i = 0; i < index; i ++)
       {
           PEGASUS_ASSERT(ptrNewElement->nextElement.start != 0);
           ptrNewElement = (SCMBUserKeyBindingElement*)
                 &(inst.base[ptrNewElement->nextElement.start]);
       }
   
       return ptrNewElement;
   }
   
   SCMBUserKeyBindingElement* SCMOInstance::_getUserDefinedKeyBinding(
       const char* name,
       Uint32 nameLen,
       CIMType type)
   {
       SCMBDataPtr newElement;
       SCMBUserKeyBindingElement* ptrNewElement;
       Uint32 node;
   
       // is the key binding already stored as user defind in the instance ?
       if (SCMO_OK == _getUserKeyBindingNodeIndex(node,name))
 { {
     if (inst.hdr->flags.isFiltered)         ptrNewElement = _getUserDefinedKeyBindingAt(node);
       }
       else // Not found, create a new user defined key binding.
     {     {
         return(inst.hdr->filterProperties);  
           _getFreeSpace(newElement,
                         sizeof(SCMBUserKeyBindingElement),
                         &inst.mem);
   
           ptrNewElement =
               (SCMBUserKeyBindingElement*)&(inst.base[newElement.start]);
   
           // link new first user defined key binding element into chain:
           // - Assing the start point of user key binding element chain
           //   to the next element of the new element.
           ptrNewElement->nextElement.start =
               inst.hdr->userKeyBindingElement.start;
           ptrNewElement->nextElement.size =
               inst.hdr->userKeyBindingElement.size;
           // - Assing the the new element
           //   to the  start point of user key binding element chain
           inst.hdr->userKeyBindingElement.start = newElement.start;
           inst.hdr->userKeyBindingElement.size = newElement.size;
           // Adjust the couter of user defined key bindings.
           inst.hdr->numberUserKeyBindings++;
   
   
           // Copy the type
           ptrNewElement->type = type;
           ptrNewElement->value.isSet=false;
   
           // Copy the key binding name including the trailing '\0'
           _setBinary(name,nameLen+1,ptrNewElement->name,&inst.mem);
   
           // reset the pointer. May the instance was reallocated.
           ptrNewElement =
               (SCMBUserKeyBindingElement*)&(inst.base[newElement.start]);
   
     }     }
  
   
       return ptrNewElement;
   
   }
   
   Uint32 SCMOInstance::getPropertyCount() const
   {
     return(inst.hdr->numberProperties);     return(inst.hdr->numberProperties);
 } }
  
Line 3594 
Line 4261 
         {         {
             return 0;             return 0;
         }         }
         av = (SCMBUnion*)&base[u->arrayValue.start];          av = (SCMBUnion*)&(base[u->arrayValue.start]);
     }     }
  
     switch (type)     switch (type)
Line 3624 
Line 4291 
             {             {
                 return(u);                 return(u);
             }             }
             break;  
         }         }
  
     case CIMTYPE_STRING:     case CIMTYPE_STRING:
Line 3646 
Line 4312 
                     ptr[i].extString.pchar =                     ptr[i].extString.pchar =
                         (char*)_getCharString(av[i].stringValue,base);                         (char*)_getCharString(av[i].stringValue,base);
                     // lenght with out the trailing /0 !                     // lenght with out the trailing /0 !
                     ptr[i].extString.length = av[i].stringValue.length-1;                      ptr[i].extString.length = av[i].stringValue.size-1;
                 }                 }
             }             }
             else             else
Line 3655 
Line 4321 
                 ptr->extString.pchar =                 ptr->extString.pchar =
                     (char*)_getCharString(u->stringValue,base);                     (char*)_getCharString(u->stringValue,base);
                 // lenght with out the trailing /0 !                 // lenght with out the trailing /0 !
                 ptr->extString.length = u->stringValue.length-1;                  ptr->extString.length = u->stringValue.size-1;
             }             }
  
              return(ptr);              return(ptr);
             break;  
         }         }
     default:     default:
         {         {
Line 3670 
Line 4335 
     return 0;     return 0;
 } }
  
   void SCMOInstance::clearKeyBindings()
   {
       _copyOnWrite();
   
       // First destroy all external references in the key bindings
       _destroyExternalKeyBindings();
   
       // reset user keybindings
       inst.hdr->numberUserKeyBindings = 0;
       inst.hdr->userKeyBindingElement.start = 0;
       inst.hdr->userKeyBindingElement.size = 0;
   
       // Allocate a clean the SCMOInstanceKeyBindingArray
       _getFreeSpace(
             inst.hdr->keyBindingArray,
             sizeof(SCMBKeyBindingValue)*inst.hdr->numberKeyBindings,
             &inst.mem);
   
       // Clear the keybindings after the allocation. Setting the keybindings
       // later causes this value to be reinitialized.
       inst.hdr->numberKeyBindings = 0;
   
       markAsCompromised();
   }
   
 Uint32 SCMOInstance::getKeyBindingCount() const Uint32 SCMOInstance::getKeyBindingCount() const
 { {
     return(inst.hdr->numberKeyBindings);      // count of class keys + user definded keys
       return(inst.hdr->numberKeyBindings+
              inst.hdr->numberUserKeyBindings);
 } }
  
  
Line 3689 
Line 4381 
     *pname = 0;     *pname = 0;
     *pvalue = 0;     *pvalue = 0;
  
     if (node >= inst.hdr->numberKeyBindings)      // count of class keys + user definded keys
       if (node >= (inst.hdr->numberKeyBindings+
                    inst.hdr->numberUserKeyBindings))
     {     {
         return SCMO_INDEX_OUT_OF_BOUND;         return SCMO_INDEX_OUT_OF_BOUND;
     }     }
Line 3724 
Line 4418 
  
     *pvalue = 0;     *pvalue = 0;
  
     rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name);      rc = inst.hdr->theClass.ptr->_getKeyBindingNodeIndex(node,name);
       if (rc != SCMO_OK)
       {
           // look at the user defined key bindings.
           rc = _getUserKeyBindingNodeIndex(node,name);
     if (rc != SCMO_OK)     if (rc != SCMO_OK)
     {     {
         return rc;         return rc;
     }     }
       }
  
     rc = _getKeyBindingDataAtNodeIndex(node,&pname,pnameLen,type,&pdata);     rc = _getKeyBindingDataAtNodeIndex(node,&pname,pnameLen,type,&pdata);
   
     if (rc != SCMO_OK)     if (rc != SCMO_OK)
     {     {
         return rc;         return rc;
Line 3754 
Line 4454 
     CIMType & type,     CIMType & type,
     const SCMBUnion** pdata) const     const SCMBUnion** pdata) const
 { {
       if (node < inst.hdr->numberKeyBindings)
       {
     SCMBKeyBindingValue* theInstKeyBindValueArray =     SCMBKeyBindingValue* theInstKeyBindValueArray =
         (SCMBKeyBindingValue*)&inst.base[inst.hdr->keyBindingArray.start];              (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
  
     // create a pointer to keybinding node array of the class.     // create a pointer to keybinding node array of the class.
     Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;          Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->
               keyBindingSet.nodeArray.start;
     SCMBKeyBindingNode* theClassKeyBindNodeArray =     SCMBKeyBindingNode* theClassKeyBindNodeArray =
         (SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]);              (SCMBKeyBindingNode*)&((inst.hdr->theClass.ptr->cls.base)[idx]);
  
     type = theClassKeyBindNodeArray[node].type;     type = theClassKeyBindNodeArray[node].type;
  
     /* First resolve pointer to the property name */          // First resolve pointer to the key binding name
     pnameLen = theClassKeyBindNodeArray[node].name.length;          pnameLen = theClassKeyBindNodeArray[node].name.size;
     *pname = _getCharString(     *pname = _getCharString(
         theClassKeyBindNodeArray[node].name,         theClassKeyBindNodeArray[node].name,
         inst.hdr->theClass->cls.base);              inst.hdr->theClass.ptr->cls.base);
  
     // There is no value set in the instance     // There is no value set in the instance
     if (!theInstKeyBindValueArray[node].isSet)     if (!theInstKeyBindValueArray[node].isSet)
Line 3777 
Line 4480 
     }     }
  
     *pdata = &(theInstKeyBindValueArray[node].data);     *pdata = &(theInstKeyBindValueArray[node].data);
       }
       else // look at the user defined key bindings
       {
   
           SCMBUserKeyBindingElement* theElem = _getUserDefinedKeyBindingAt(node);
   
           type = theElem->type;
   
           pnameLen = theElem->name.size;
           *pname = _getCharString(theElem->name,inst.base);
  
           // There is no value set in the instance
           if (!theElem->value.isSet)
           {
               return SCMO_NULL_VALUE;
           }
   
           *pdata = &(theElem->value.data);
   
       }
   
       return SCMO_OK;
   }
   
   SCMO_RC SCMOInstance::_getUserKeyBindingNodeIndex(
       Uint32& node,
       const char* name) const
   {
   
       Uint32 len = strlen(name);
       node = 0;
   
       Uint64 elementStart = inst.hdr->userKeyBindingElement.start;
   
       while (elementStart != 0)
       {
           SCMBUserKeyBindingElement* theUserDefKBElement =
               (SCMBUserKeyBindingElement*)&(inst.base[elementStart]);
   
           if (_equalNoCaseUTF8Strings(
               theUserDefKBElement->name,inst.base,name,len))
           {
               // the node index of a user defined key binding has an offset
               // by the number of key bindings defined in the class
               node = node + inst.hdr->numberKeyBindings;
     return SCMO_OK;     return SCMO_OK;
 } }
           node = node + 1;
           elementStart = theUserDefKBElement->nextElement.start;
       }
   
       return SCMO_NOT_FOUND;
   
   }
   
   CIMType SCMOInstance::_CIMTypeFromKeyBindingType(
       const char* key,
       CIMKeyBinding::Type t)
   {
       switch( t )
       {
           case CIMKeyBinding::NUMERIC:
               {
                   if( *(key)=='-' )
                   {
                      Sint64 x;
                      // check if it is realy an integer
                      if (StringConversion::stringToSignedInteger(key, x))
                      {
                          return CIMTYPE_SINT64;
                      }
                      else
                      {
                          return CIMTYPE_REAL64;
                      }
                   }
                   else
                   {
                       Uint64 x;
                       // check if it is realy an integer
                       if (StringConversion::stringToUnsignedInteger(key, x))
                       {
                           return CIMTYPE_UINT64;
                       }
                       else
                       {
                           return CIMTYPE_REAL64;
                       }
                   }
               }
   
   
           case CIMKeyBinding::STRING:
           {
               return CIMTYPE_STRING;
           }
   
           case CIMKeyBinding::BOOLEAN:
           {
               return CIMTYPE_BOOLEAN;
           }
   
           case CIMKeyBinding::REFERENCE:
           {
               return CIMTYPE_REFERENCE;
           }
   
           default:
               return CIMTYPE_UINT64;
       }
       return CIMTYPE_UINT64;
   }
  
 Boolean SCMOInstance::_setCimKeyBindingStringToSCMOKeyBindingValue( Boolean SCMOInstance::_setCimKeyBindingStringToSCMOKeyBindingValue(
     const String& kbs,     const String& kbs,
Line 3788 
Line 4600 
     )     )
 { {
     scmoKBV.isSet=false;     scmoKBV.isSet=false;
       // If it not a simple value, it will be over written.
       scmoKBV.data.simple.hasValue=false;
  
     if ( kbs.size() == 0 && type != CIMTYPE_STRING)     if ( kbs.size() == 0 && type != CIMTYPE_STRING)
     {     {
Line 3807 
Line 4621 
                 StringConversion::checkUintBounds(x, type))                 StringConversion::checkUintBounds(x, type))
             {             {
               scmoKBV.data.simple.val.u8 = Uint8(x);               scmoKBV.data.simple.val.u8 = Uint8(x);
                 scmoKBV.data.simple.hasValue=true;
               scmoKBV.isSet=true;               scmoKBV.isSet=true;
             }             }
             break;             break;
Line 3818 
Line 4633 
                 StringConversion::checkUintBounds(x, type))                 StringConversion::checkUintBounds(x, type))
             {             {
               scmoKBV.data.simple.val.u16 = Uint16(x);               scmoKBV.data.simple.val.u16 = Uint16(x);
                 scmoKBV.data.simple.hasValue=true;
               scmoKBV.isSet=true;               scmoKBV.isSet=true;
             }             }
             break;             break;
Line 3830 
Line 4646 
                 StringConversion::checkUintBounds(x, type))                 StringConversion::checkUintBounds(x, type))
             {             {
               scmoKBV.data.simple.val.u32 = Uint32(x);               scmoKBV.data.simple.val.u32 = Uint32(x);
                 scmoKBV.data.simple.hasValue=true;
               scmoKBV.isSet=true;               scmoKBV.isSet=true;
             }             }
             break;             break;
Line 3841 
Line 4658 
             if (StringConversion::stringToUnsignedInteger(v, x))             if (StringConversion::stringToUnsignedInteger(v, x))
             {             {
               scmoKBV.data.simple.val.u64 = x;               scmoKBV.data.simple.val.u64 = x;
                 scmoKBV.data.simple.hasValue=true;
               scmoKBV.isSet=true;               scmoKBV.isSet=true;
             }             }
             break;             break;
Line 3853 
Line 4671 
                 StringConversion::checkSintBounds(x, type))                 StringConversion::checkSintBounds(x, type))
             {             {
               scmoKBV.data.simple.val.s8 = Sint8(x);               scmoKBV.data.simple.val.s8 = Sint8(x);
                 scmoKBV.data.simple.hasValue=true;
               scmoKBV.isSet=true;               scmoKBV.isSet=true;
             }             }
             break;             break;
Line 3865 
Line 4684 
                 StringConversion::checkSintBounds(x, type))                 StringConversion::checkSintBounds(x, type))
             {             {
               scmoKBV.data.simple.val.s16 = Sint16(x);               scmoKBV.data.simple.val.s16 = Sint16(x);
                 scmoKBV.data.simple.hasValue=true;
               scmoKBV.isSet=true;               scmoKBV.isSet=true;
             }             }
             break;             break;
Line 3877 
Line 4697 
                 StringConversion::checkSintBounds(x, type))                 StringConversion::checkSintBounds(x, type))
             {             {
               scmoKBV.data.simple.val.s32 = Sint32(x);               scmoKBV.data.simple.val.s32 = Sint32(x);
                 scmoKBV.data.simple.hasValue=true;
               scmoKBV.isSet=true;               scmoKBV.isSet=true;
             }             }
             break;             break;
Line 3888 
Line 4709 
             if (StringConversion::stringToSignedInteger(v, x))             if (StringConversion::stringToSignedInteger(v, x))
             {             {
               scmoKBV.data.simple.val.s64 = x;               scmoKBV.data.simple.val.s64 = x;
                 scmoKBV.data.simple.hasValue=true;
               scmoKBV.isSet=true;               scmoKBV.isSet=true;
             }             }
             break;             break;
Line 3918 
Line 4740 
         {         {
             Real64 x;             Real64 x;
  
             if (!StringConversion::stringToReal64(v, x))              if (StringConversion::stringToReal64(v, x))
             {             {
               scmoKBV.data.simple.val.r32 = Real32(x);               scmoKBV.data.simple.val.r32 = Real32(x);
                 scmoKBV.data.simple.hasValue=true;
               scmoKBV.isSet=true;               scmoKBV.isSet=true;
             }             }
             break;             break;
Line 3930 
Line 4753 
         {         {
             Real64 x;             Real64 x;
  
             if (!StringConversion::stringToReal64(v, x))              if (StringConversion::stringToReal64(v, x))
             {             {
               scmoKBV.data.simple.val.r32 = x;                scmoKBV.data.simple.val.r64 = x;
                 scmoKBV.data.simple.hasValue=true;
               scmoKBV.isSet=true;               scmoKBV.isSet=true;
             }             }
             break;             break;
Line 3943 
Line 4767 
             if (kbs.size() == 1)             if (kbs.size() == 1)
             {             {
                 scmoKBV.data.simple.val.c16 = kbs[0];                 scmoKBV.data.simple.val.c16 = kbs[0];
                   scmoKBV.data.simple.hasValue=true;
                 scmoKBV.isSet=true;                 scmoKBV.isSet=true;
             }             }
             break;             break;
Line 3952 
Line 4777 
             if (String::equalNoCase(kbs,"TRUE"))             if (String::equalNoCase(kbs,"TRUE"))
             {             {
                 scmoKBV.data.simple.val.bin = true;                 scmoKBV.data.simple.val.bin = true;
                   scmoKBV.data.simple.hasValue=true;
                 scmoKBV.isSet=true;                 scmoKBV.isSet=true;
             }             }
             else if (String::equalNoCase(kbs,"FALSE"))             else if (String::equalNoCase(kbs,"FALSE"))
                  {                  {
                      scmoKBV.data.simple.val.bin = false;                      scmoKBV.data.simple.val.bin = false;
                        scmoKBV.data.simple.hasValue=true;
                      scmoKBV.isSet=true;                      scmoKBV.isSet=true;
                  }                  }
             break;             break;
Line 3968 
Line 4795 
             // Can cause reallocation !             // Can cause reallocation !
             _setString(kbs,scmoKBV.data.stringValue,&inst.mem);             _setString(kbs,scmoKBV.data.stringValue,&inst.mem);
             return true;             return true;
             break;  
         }         }
     case CIMTYPE_REFERENCE:     case CIMTYPE_REFERENCE:
         {         {
Line 3980 
Line 4806 
             }             }
             // TBD: Optimize parsing and SCMOInstance creation.             // TBD: Optimize parsing and SCMOInstance creation.
             CIMObjectPath theCIMObj(kbs);             CIMObjectPath theCIMObj(kbs);
             SCMOClass* theRefClass = _getSCMOClass(theCIMObj);  
             if (theRefClass != 0)              scmoKBV.data.extRefPtr = new SCMOInstance(theCIMObj);
             {              scmoKBV.isSet=true;
                 scmoKBV.data.extRefPtr =  
                     new SCMOInstance(*theRefClass,theCIMObj);              // Was the conversion successful?
             } else              if (scmoKBV.data.extRefPtr->isEmpty())
             {             {
                   // N0, delete the SCMOInstance.
                   delete scmoKBV.data.extRefPtr;
                 scmoKBV.data.extRefPtr = 0;                 scmoKBV.data.extRefPtr = 0;
                   scmoKBV.isSet=false;
               }
               else
               {
                   // This function can cause a reallocation !
                   // Pointers can be invalid after the call.
                   _setExtRefIndex(&(scmoKBV.data),&inst.mem);
             }             }
             scmoKBV.isSet=true;  
             break;             break;
         }         }
     case CIMTYPE_OBJECT:     case CIMTYPE_OBJECT:
Line 3997 
Line 4831 
         {         {
             // From PEP 194: EmbeddedObjects cannot be keys.             // From PEP 194: EmbeddedObjects cannot be keys.
             throw TypeMismatchException();             throw TypeMismatchException();
             break;  
         }         }
     default:     default:
         {         {
Line 4011 
Line 4844 
  
 SCMO_RC SCMOInstance::_setKeyBindingFromString( SCMO_RC SCMOInstance::_setKeyBindingFromString(
     const char* name,     const char* name,
       CIMType type,
     String cimKeyBinding)     String cimKeyBinding)
 { {
     SCMO_RC rc;  
     Uint32 node;     Uint32 node;
  
     if (0 == name)     if (0 == name)
Line 4021 
Line 4854 
         return SCMO_INVALID_PARAMETER;         return SCMO_INVALID_PARAMETER;
     }     }
  
     rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name);      if (SCMO_OK == inst.hdr->theClass.ptr->_getKeyBindingNodeIndex(node,name))
     if (rc != SCMO_OK)  
     {     {
         return rc;  
     }  
   
    // create a pointer to keybinding node array of the class.    // create a pointer to keybinding node array of the class.
     Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;          Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->
               keyBindingSet.nodeArray.start;
     SCMBKeyBindingNode* theClassKeyBindNodeArray =     SCMBKeyBindingNode* theClassKeyBindNodeArray =
         (SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]);              (SCMBKeyBindingNode*)&((inst.hdr->theClass.ptr->cls.base)[idx]);
  
     // create a pointer to instance keybinding values     // create a pointer to instance keybinding values
     SCMBKeyBindingValue* theInstKeyBindValueArray =     SCMBKeyBindingValue* theInstKeyBindValueArray =
Line 4048 
Line 4878 
     return SCMO_OK;     return SCMO_OK;
 } }
  
       // the key binig does not belong to the associated class
       // add/set it as user defined key binding.
       SCMBUserKeyBindingElement* ptrNewElement;
   
       ptrNewElement = _getUserDefinedKeyBinding( name,strlen(name),type);
   
       // Copy the data.
       // If the set was not successful, the conversion was not successful
       if ( !_setCimKeyBindingStringToSCMOKeyBindingValue(
               cimKeyBinding,
               type,
               ptrNewElement->value))
       {
           return SCMO_TYPE_MISSMATCH;
       }
   
       return SCMO_OK;
   }
   
 SCMO_RC SCMOInstance::setKeyBinding( SCMO_RC SCMOInstance::setKeyBinding(
     const char* name,     const char* name,
     CIMType type,     CIMType type,
Line 4061 
Line 4910 
         return SCMO_INVALID_PARAMETER;         return SCMO_INVALID_PARAMETER;
     }     }
  
     rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name);      if (0 == keyvalue)
       {
           return SCMO_INVALID_PARAMETER;
       }
   
       _copyOnWrite();
   
       // If keybindings exists and cleared using the clearKeyBindings()
       // method, reset the value to the actual keybindings count exists
       // in the class.
       if (!inst.hdr->numberKeyBindings)
       {
           inst.hdr->numberKeyBindings =
               inst.hdr->theClass.ptr->cls.hdr->keyBindingSet.number;
       }
   
       rc = inst.hdr->theClass.ptr->_getKeyBindingNodeIndex(node,name);
     if (rc != SCMO_OK)     if (rc != SCMO_OK)
     {     {
         return rc;          // the key bindig does not belong to the associated class
           // add/set it as user defined key binding.
           SCMBUserKeyBindingElement *theNode;
   
           theNode = _getUserDefinedKeyBinding( name,strlen(name),type);
   
           // Is this a new node or an existing user key binding?
           if (theNode->value.isSet && (theNode->type != type))
           {
               return SCMO_TYPE_MISSMATCH;
   
           }
   
           theNode->value.isSet=true;
   
           _setSCMBUnion(
               keyvalue,
               type,
               false, // a key binding can never be an array.
               0,
               theNode->value.data);
   
            return SCMO_OK;
     }     }
  
     return setKeyBindingAt(node, type, keyvalue);     return setKeyBindingAt(node, type, keyvalue);
Line 4075 
Line 4962 
         CIMType type,         CIMType type,
         const SCMBUnion* keyvalue)         const SCMBUnion* keyvalue)
 { {
     SCMO_RC rc;  
   
    // create a pointer to keybinding node array of the class.  
     Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;  
     SCMBKeyBindingNode* theClassKeyBindNodeArray =  
         (SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]);  
   
     if (0 == keyvalue)     if (0 == keyvalue)
     {     {
         return SCMO_INVALID_PARAMETER;         return SCMO_INVALID_PARAMETER;
     }     }
  
     if (node >= inst.hdr->numberKeyBindings)      // count of class keys + user definded keys
       if (node >= (inst.hdr->numberKeyBindings+
                    inst.hdr->numberUserKeyBindings))
     {     {
         return SCMO_INDEX_OUT_OF_BOUND;         return SCMO_INDEX_OUT_OF_BOUND;
     }     }
  
     if (theClassKeyBindNodeArray[node].type != type)      _copyOnWrite();
   
       // If keybindings exists and cleared using the clearKeyBindings()
       // method, reset the value to the actual keybindings count exists
       // in the class.
       if (!inst.hdr->numberKeyBindings)
       {
           inst.hdr->numberKeyBindings =
               inst.hdr->theClass.ptr->cls.hdr->keyBindingSet.number;
       }
   
   
      // create a pointer to keybinding node array of the class.
       Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->
           keyBindingSet.nodeArray.start;
       SCMBKeyBindingNode* theClassKeyBindNodeArray =
           (SCMBKeyBindingNode*)&((inst.hdr->theClass.ptr->cls.base)[idx]);
   
       // is the node a user defined key binding ?
       if (node >= inst.hdr->numberKeyBindings)
       {
           SCMBUserKeyBindingElement* theNode = _getUserDefinedKeyBindingAt(node);
   
           // Does the new value for the user defined keybinding match?
           if (theNode->type != type)
     {     {
         return SCMO_TYPE_MISSMATCH;         return SCMO_TYPE_MISSMATCH;
     }     }
  
           _setSCMBUnion(
               keyvalue,
               type,
               false, // a key binding can never be an array.
               0,
               theNode->value.data);
   
            return SCMO_OK;
   
       }
   
     SCMBKeyBindingValue* theInstKeyBindValueArray =     SCMBKeyBindingValue* theInstKeyBindValueArray =
         (SCMBKeyBindingValue*)&inst.base[inst.hdr->keyBindingArray.start];          (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
  
  
       if (theClassKeyBindNodeArray[node].type == type)
       {
   
     // Has to be set first,     // Has to be set first,
     // because reallocaton can take place in _setSCMBUnion()     // because reallocaton can take place in _setSCMBUnion()
     theInstKeyBindValueArray[node].isSet=true;     theInstKeyBindValueArray[node].isSet=true;
Line 4113 
Line 5033 
         theInstKeyBindValueArray[node].data);         theInstKeyBindValueArray[node].data);
  
     return SCMO_OK;     return SCMO_OK;
   
 } }
  
       // The type does not match.
       return _setKeyBindingTypeTolerate(
           theClassKeyBindNodeArray[node].type,
           type,
           keyvalue,
           theInstKeyBindValueArray[node]);
  
 void SCMOInstance::setPropertyFilter(const char **propertyList)  }
 {  
     SCMO_RC rc;  
     Uint32 node,i = 0;  
  
     if (inst.hdr->propertyFilter.start == 0)  /**
    * Set a SCMO user defined key binding using the class CIM type tolerating
    * CIM key binding types converted to CIM types by fuction
    *  _CIMTypeFromKeyBindingType().
    *
    * @parm classType The type of the key binding in the class definition
    * @parm setType The type of the key binding to be set.
    * @param keyValue A pointer to the key binding to be set.
    * @param kbValue Out parameter, the SCMO keybinding to be set.
    *
    **/
   SCMO_RC SCMOInstance::_setKeyBindingTypeTolerate(
       CIMType classType,
       CIMType setType,
       const SCMBUnion* keyValue,
       SCMBKeyBindingValue& kbValue)
   {
       if (setType == CIMTYPE_UINT64 )
       {
           switch (classType)
     {     {
         // Allocate the SCMBPropertyFilter  
         _getFreeSpace(  
             inst.hdr->propertyFilter,  
             sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1),  
             &inst.mem,  
             true);  
  
         // Allocate the SCMBPropertyFilterIndexMap          case CIMTYPE_UINT8:
         _getFreeSpace(              {
             inst.hdr->propertyFilterIndexMap,                  kbValue.isSet=true;
             sizeof(Uint32)*inst.hdr->numberProperties,                  kbValue.data.simple.hasValue=true;
             &inst.mem,                  kbValue.data.simple.val.u8=Uint8(keyValue->simple.val.u64);
             true);                  break;
     }     }
     // Get absolut pointer to property filter index map of the instance          case CIMTYPE_UINT16:
     Uint32* propertyFilterIndexMap =              {
         (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);                  kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
     // All properties are accepted                  kbValue.data.simple.val.u16=Uint16(keyValue->simple.val.u64);
     if (propertyList == 0)                  break;
     {  
         // Clear filtering:  
         // Switch filtering off.  
         inst.hdr->flags.isFiltered = false;  
   
         // Clear filter index map  
         memset(  
             propertyFilterIndexMap,  
             0,  
             sizeof(Uint32)*inst.hdr->numberProperties);  
   
         //reset number filter properties to all  
         inst.hdr->filterProperties = inst.hdr->numberProperties;  
   
         return;  
     }     }
           case CIMTYPE_UINT32:
     // Switch filtering on.  
     inst.hdr->flags.isFiltered = true;  
   
     // intit the filter with the key properties  
     inst.hdr->filterProperties=_initPropFilterWithKeys();  
   
     // add the properties to the filter.  
     while (propertyList[i] != 0)  
     {     {
         // the hash index of the property if the property name is found                  kbValue.isSet=true;
         rc = inst.hdr->theClass->_getProperyNodeIndex(node,propertyList[i]);                  kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.u32=Uint32(keyValue->simple.val.u64);
         // if property is already in the filter                  break;
         // ( eg. key properties ) do not add them !  
         if (rc == SCMO_OK && !_isPropertyInFilter(node))  
         {  
             // The property name was found. Otherwise ignore this property name.  
             // insert the hash index into the filter index map  
             propertyFilterIndexMap[inst.hdr->filterProperties]=node;  
             // increase number of properties in filter.  
             inst.hdr->filterProperties++;  
             // set bit in the property filter  
             _setPropertyInPropertyFilter(node);  
         }         }
         // Proceed with the next property name.          case CIMTYPE_UINT64:
         i++;              {
                   kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.u64=keyValue->simple.val.u64;
                   break;
               }
           default:
               {
                   return SCMO_TYPE_MISSMATCH;
     }     }
   
 } }
           return SCMO_OK;
  
       }
  
 Uint32 SCMOInstance::_initPropFilterWithKeys()      if (setType == CIMTYPE_SINT64)
       {
           switch (classType)
 { {
  
     // Get absolut pointer to the key property mask of the class.          case CIMTYPE_SINT8:
     Uint64 idx = inst.hdr->theClass->cls.hdr->keyPropertyMask.start;              {
     Uint64* keyMask =(Uint64*)&(inst.hdr->theClass->cls.base)[idx];                  kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
     // Get absolut pointer to property filter mask                  kbValue.data.simple.val.s8=Sint8(keyValue->simple.val.s64);
     Uint64* propertyFilterMask =                  break;
         (Uint64*)&(inst.base[inst.hdr->propertyFilter.start]);  
   
     // copy the key mask to the property filter mask  
     memcpy(  
         propertyFilterMask,  
         keyMask,  
         sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1));  
   
     // Get absolut pointer to key index list of the class  
     idx=inst.hdr->theClass->cls.hdr->keyIndexList.start;  
     Uint32* keyIndex = (Uint32*)&(inst.hdr->theClass->cls.base)[idx];  
   
     // Get absolut pointer to property filter index map of the instance  
     Uint32* propertyFilterIndexMap =  
         (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);  
   
     Uint32 noKeys = inst.hdr->theClass->cls.hdr->keyBindingSet.number;  
     memcpy(propertyFilterIndexMap,keyIndex,sizeof(Uint32)*noKeys);  
   
     // return the number of properties already in the filter index map  
     return noKeys;  
   
 } }
           case CIMTYPE_SINT16:
 void SCMOInstance::_clearPropertyFilter()  
 { {
     Uint64 *propertyFilter;                  kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
     // Calculate the real pointer to the Uint64 array                  kbValue.data.simple.val.s16=Sint16(keyValue->simple.val.s64);
     propertyFilter = (Uint64*)&inst.base[inst.hdr->propertyFilter.start];                  break;
   
     // the number of Uint64 in the key mask is :  
     // Decrease the number of properties by 1  
     // since the array is starting at index 0!  
     // Divide with the number of bits in a Uint64.  
     // e.g. number of Properties = 68  
     // (68 - 1) / 64 = 1 --> The mask consists of 2 Uint64  
   
     memset(propertyFilter,  
            0,  
            sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1));  
   
 } }
 void SCMOInstance::_setPropertyInPropertyFilter(Uint32 i)          case CIMTYPE_SINT32:
 { {
     Uint64 *propertyFilter;                  kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
     // In which Uint64 of key mask is the bit for property i ?                  kbValue.data.simple.val.s32=Sint32(keyValue->simple.val.s64);
     // Divide with the number of bits in a Uint64.                  break;
     // 47 / 64 = 0 --> The key bit for property i is in in keyMask[0].              }
     Uint32 idx = i/64 ;          case CIMTYPE_SINT64:
               {
     // Create a filter to set the bit.                  kbValue.isSet=true;
     // Modulo division with 64. Shift left a bit by the remainder.                  kbValue.data.simple.hasValue=true;
     Uint64 filter = ( (Uint64)1 << (i%64));                  kbValue.data.simple.val.s64=keyValue->simple.val.s64;
                   break;
     // Calculate the real pointer to the Uint64 array              }
     propertyFilter = (Uint64*)&(inst.base[inst.hdr->propertyFilter.start]);          default:
               {
                   return SCMO_TYPE_MISSMATCH;
               }
           }
           return SCMO_OK;
       }
  
     propertyFilter[idx] = propertyFilter[idx] | filter ;      if (setType == CIMTYPE_REAL64)
       {
           switch (classType)
           {
           case CIMTYPE_REAL32:
               {
                   kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.r32=Real32(keyValue->simple.val.r64);
                   break;
               }
           case CIMTYPE_REAL64:
               {
                   kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.r64=keyValue->simple.val.r64;
                   break;
               }
           default:
               {
                   return SCMO_TYPE_MISSMATCH;
               }
           }
           return SCMO_OK;
 } }
       else
 Boolean SCMOInstance::_isPropertyInFilter(Uint32 i) const  
 { {
     Uint64 *propertyFilter;          // If type defined in the class and the provided type does not match
           // at this point, no convertaion can be done and the provided type
     // In which Uint64 of key mask is the bit for property i ?          // is handlend as type missmatch.
     // Divide with the number of bits in a Uint64.          if (classType != setType)
     // e.g. number of Properties = 68          {
     // 47 / 64 = 0 --> The key bit for property i is in in keyMask[0].              return SCMO_TYPE_MISSMATCH;
     Uint32 idx = i/64 ;          }
   
     // Create a filter to check if the bit is set:  
     // Modulo division with 64. Shift left a bit by the remainder.  
     Uint64 filter = ( (Uint64)1 << (i%64));  
  
     // Calculate the real pointer to the Uint64 array          switch (classType)
     propertyFilter = (Uint64*)&inst.base[inst.hdr->propertyFilter.start];          {
           case CIMTYPE_DATETIME:
           case CIMTYPE_BOOLEAN:
           case CIMTYPE_UINT64:
           case CIMTYPE_SINT64:
           case CIMTYPE_REAL64:
           case CIMTYPE_STRING:
           case CIMTYPE_REFERENCE:
               {
                   kbValue.isSet=true;
                   _setSCMBUnion(keyValue,classType,false, 0,kbValue.data);
                   return SCMO_OK;
               }
           default:
               {
                   return SCMO_TYPE_MISSMATCH;
               }
           }
       }
  
     // If the bit is set the property is NOT filtered.      return SCMO_TYPE_MISSMATCH;
     // So the result has to be negated!  
     return propertyFilter[idx] & filter ;  
  
 } }
  
   // class SCMODump only in debug builds available
   #ifdef PEGASUS_DEBUG
 /****************************************************************************** /******************************************************************************
  * SCMODump Print and Dump functions  * SCMODump Print and Dump functions
  *****************************************************************************/  *****************************************************************************/
 SCMODump::SCMODump() SCMODump::SCMODump()
 { {
     _out = stdout;      _out = stderr;
     _fileOpen = false;     _fileOpen = false;
  
 #ifdef PEGASUS_OS_ZOS #ifdef PEGASUS_OS_ZOS
Line 4299 
Line 5221 
  
 } }
  
 SCMODump::SCMODump(char* filename)  SCMODump::SCMODump(const char* filename)
 { {
     openFile(filename);     openFile(filename);
 } }
  
 void SCMODump::openFile(char* filename)  void SCMODump::openFile(const char* filename)
 { {
     const char* pegasusHomeDir = getenv("PEGASUS_HOME");     const char* pegasusHomeDir = getenv("PEGASUS_HOME");
  
Line 4358 
Line 5280 
  
 Boolean SCMODump::compareFile(String master) Boolean SCMODump::compareFile(String master)
 { {
   
     if (!_fileOpen)     if (!_fileOpen)
     {     {
         return false;         return false;
     }     }
   
     closeFile();     closeFile();
  
     return (FileSystem::compareFiles(_filename, master));      ifstream isMaster;
       ifstream isDumpFile;
   
       Open(isDumpFile, _filename);
       Open(isMaster, master);
   
       String aLine;
       String bLine;
   
       while (GetLine(isDumpFile, aLine) && GetLine(isMaster, bLine))
       {
           if (aLine != bLine)
           {
               cout << "|" << aLine << "|" << endl;
               cout << "|" << bLine << "|" << endl;
               isDumpFile.close();
               isMaster.close();
               return false;
           }
       };
       isDumpFile.close();
       isMaster.close();
       return true;
 } }
  
 void SCMODump::dumpSCMOInstance(SCMOInstance& testInst) const  void SCMODump::dumpSCMOInstance(SCMOInstance& testInst, Boolean inclMemHdr)const
 { {
     SCMBInstance_Main* insthdr = testInst.inst.hdr;     SCMBInstance_Main* insthdr = testInst.inst.hdr;
     char* instbase = testInst.inst.base;     char* instbase = testInst.inst.base;
  
     fprintf(_out,"\n\nDump of SCMOInstance\n");     fprintf(_out,"\n\nDump of SCMOInstance\n");
     // The magic number for SCMO class  
     fprintf(_out,"\nheader.magic=%08X",insthdr->header.magic);      if (inclMemHdr)
     // Total size of the instance memory block( # bytes )      {
     fprintf(_out,"\nheader.totalSize=%llu",insthdr->header.totalSize);          _dumpSCMBMgmt_Header(insthdr->header,instbase);
       }
   
     // The reference counter for this c++ class     // The reference counter for this c++ class
     fprintf(_out,"\nrefCount=%i",insthdr->refCount.get());     fprintf(_out,"\nrefCount=%i",insthdr->refCount.get());
     fprintf(_out,"\ntheClass: %p",insthdr->theClass);      fprintf(_out,"\ntheClass: %p",insthdr->theClass.ptr);
     fprintf(_out,"\n\nThe Flags:");     fprintf(_out,"\n\nThe Flags:");
     fprintf(_out,"\n   includeQualifiers: %s",     fprintf(_out,"\n   includeQualifiers: %s",
            (insthdr->flags.includeQualifiers ? "True" : "False"));            (insthdr->flags.includeQualifiers ? "True" : "False"));
     fprintf(_out,"\n   includeClassOrigin: %s",     fprintf(_out,"\n   includeClassOrigin: %s",
            (insthdr->flags.includeClassOrigin ? "True" : "False"));            (insthdr->flags.includeClassOrigin ? "True" : "False"));
     fprintf(_out,"\n   isFiltered: %s",      fprintf(_out,"\n   isClassOnly: %s",
            (insthdr->flags.isFiltered ? "True" : "False"));             (insthdr->flags.isClassOnly ? "True" : "False"));
       fprintf(_out,"\n   isCompromised: %s",
              (insthdr->flags.isCompromised ? "True" : "False"));
       fprintf(_out,"\n   exportSetOnly: %s",
              (insthdr->flags.exportSetOnly ? "True" : "False"));
       fprintf(_out,"\n\ninstNameSpace: \'%s\'",
              NULLSTR(_getCharString(insthdr->instNameSpace,instbase)));
       fprintf(_out,"\n\ninstClassName: \'%s\'",
              NULLSTR(_getCharString(insthdr->instClassName,instbase)));
     fprintf(_out,"\n\nhostName: \'%s\'",     fprintf(_out,"\n\nhostName: \'%s\'",
            NULLSTR(_getCharString(insthdr->hostName,instbase)));            NULLSTR(_getCharString(insthdr->hostName,instbase)));
  
     dumpSCMOInstanceKeyBindings(testInst);     dumpSCMOInstanceKeyBindings(testInst);
  
     dumpSCMOInstancePropertyFilter(testInst);  
   
     dumpInstanceProperties(testInst);     dumpInstanceProperties(testInst);
     fprintf(_out,"\n\n");     fprintf(_out,"\n\n");
  
 } }
  
 void SCMODump::dumpSCMOInstancePropertyFilter(SCMOInstance& testInst) const  void SCMODump::dumpInstanceProperties(
 {      SCMOInstance& testInst,
     SCMBInstance_Main* insthdr = testInst.inst.hdr;      Boolean verbose) const
     char* instbase = testInst.inst.base;  
   
     if (!insthdr->flags.isFiltered)  
     {  
         fprintf(_out,"\n\nNo propterty filter!\n\n");  
         return;  
     }  
   
     fprintf(_out,"\n\nInstance Property Filter :");  
     fprintf(_out,"\n==========================");  
     fprintf(_out,"\n\nNumber of properties in the filter : %u\n"  
         ,insthdr->filterProperties);  
   
     dumpPropertyFilter(testInst);  
   
     dumpPropertyFilterIndexMap(testInst);  
   
 }  
   
 void SCMODump::dumpInstanceProperties(SCMOInstance& testInst) const  
 { {
     SCMBInstance_Main* insthdr = testInst.inst.hdr;     SCMBInstance_Main* insthdr = testInst.inst.hdr;
     char* instbase = testInst.inst.base;     char* instbase = testInst.inst.base;
Line 4439 
Line 5369 
     for (Uint32 i = 0, k = insthdr->numberProperties; i < k; i++)     for (Uint32 i = 0, k = insthdr->numberProperties; i < k; i++)
     {     {
         fprintf(_out,"\n\nInstance property (#%3u) %s\n",i,         fprintf(_out,"\n\nInstance property (#%3u) %s\n",i,
                 NULLSTR(insthdr->theClass->_getPropertyNameAtNode(i)));                  NULLSTR(insthdr->theClass.ptr->_getPropertyNameAtNode(i)));
         if(insthdr->flags.isFiltered && !testInst._isPropertyInFilter(i))  
         {          printSCMOValue(val[i],instbase,verbose);
             fprintf(_out,"\nProperty is filtered out!");  
         }  
         else  
         {  
             printSCMOValue(val[i],instbase);  
         }  
     }     }
  
 } }
  
 void SCMODump::dumpPropertyFilterIndexMap(SCMOInstance& testInst) const  
 {  
  
   void SCMODump::dumpSCMOInstanceKeyBindings(
       SCMOInstance& testInst,
       Boolean verbose) const
   {
     SCMBInstance_Main* insthdr = testInst.inst.hdr;     SCMBInstance_Main* insthdr = testInst.inst.hdr;
     char* instbase = testInst.inst.base;     char* instbase = testInst.inst.base;
  
     if (!insthdr->flags.isFiltered)      // create a pointer to keybinding node array of the class.
     {      Uint64 idx = insthdr->theClass.ptr->cls.hdr->keyBindingSet.nodeArray.start;
         fprintf(_out,"\n\nNo propterty filter!\n\n");      SCMBKeyBindingNode* theClassKeyBindNodeArray =
         return;          (SCMBKeyBindingNode*)&((insthdr->theClass.ptr->cls.base)[idx]);
     }  
   
     fprintf(_out,"\n\nProperty Filter Index Max:");  
     fprintf(_out,"\n==========================\n");  
  
     // Get absolut pointer to key index list of the class      SCMBKeyBindingValue* ptr =
     Uint32* keyIndex =          (SCMBKeyBindingValue*)
         (Uint32*)&(instbase)[insthdr->propertyFilterIndexMap.start];               _resolveDataPtr(insthdr->keyBindingArray,instbase);
  
     Uint32 line,j,i,k = insthdr->filterProperties;      fprintf(_out,"\n\nInstance Key Bindings :");
       fprintf(_out,"\n=======================");
       fprintf(_out,"\n\nNumber of Key Bindings defined in the Class: %u",
               insthdr->numberKeyBindings);
  
     for (j = 0; j < k; j = j + line)      for (Uint32 i = 0, k = insthdr->numberKeyBindings; i < k; i++)
     {     {
         if ((insthdr->filterProperties-j)/16)          if (ptr[i].isSet)
         {         {
             line = 16 ;              fprintf(_out,"\n\nName: '%s'\nType: '%s'",
                   NULLSTR(_getCharString(
                       theClassKeyBindNodeArray[i].name,
                       insthdr->theClass.ptr->cls.base)),
                   cimTypeToString(theClassKeyBindNodeArray[i].type));
               printUnionValue(
                   theClassKeyBindNodeArray[i].type,
                   ptr[i].data,
                   instbase,
                   verbose);
         }         }
         else         else
         {         {
             line = insthdr->filterProperties%16;              fprintf(_out,"\n\nName: '%s': Not Set",
         }                  NULLSTR(_getCharString(
                       theClassKeyBindNodeArray[i].name,
                       insthdr->theClass.ptr->cls.base)));
         fprintf(_out,"Index :");  
         for (i = 0; i < line; i++)  
         {  
             fprintf(_out," %3u",j+i);  
         }  
   
         fprintf(_out,"\nNode  :");  
         for (i = 0; i < line; i++)  
         {  
             fprintf(_out," %3u",keyIndex[j+i]);  
         }         }
   
         fprintf(_out,"\n\n");  
   
     }     }
  
 }      fprintf(_out,"\n\nNumber of User Defined Key Bindings: %u",
               insthdr->numberUserKeyBindings);
  
 void SCMODump::dumpPropertyFilter(SCMOInstance& testInst) const  
 {  
  
     SCMBInstance_Main* insthdr = testInst.inst.hdr;      SCMBUserKeyBindingElement* theUserDefKBElement;
     char* instbase = testInst.inst.base;  
  
     if (!insthdr->flags.isFiltered)      Uint64 start = insthdr->userKeyBindingElement.start;
       while (start != 0)
     {     {
         fprintf(_out,"\n\nNo propterty filter!");          theUserDefKBElement = (SCMBUserKeyBindingElement*)&(instbase[start]);
         return;  
     }  
   
     Uint64 *thePropertyFilter =  
         (Uint64*)&(instbase[insthdr->propertyFilter.start]);  
      Uint32 end, noProperties = insthdr->numberProperties;  
      Uint32 noMasks = (noProperties-1)/64;  
      Uint64 printMask = 1;  
  
      for (Uint32 i = 0; i <= noMasks; i++ )          if (theUserDefKBElement->value.isSet)
      {  
          printMask = 1;  
          if (i < noMasks)  
          {          {
              end = 64;              fprintf(_out,"\n\nName: '%s'\nType: '%s'",
                   NULLSTR(_getCharString(theUserDefKBElement->name,instbase)),
                   cimTypeToString(theUserDefKBElement->type));
               printUnionValue(
                   theUserDefKBElement->type,
                   theUserDefKBElement->value.data,
                   instbase,
                   verbose);
          }          }
          else          else
          {          {
              end = noProperties%64;              fprintf(_out,"\n\n    %s : Not Set",
          }                  NULLSTR(_getCharString(theUserDefKBElement->name,instbase)));
  
          fprintf(_out,"\npropertyFilter[%02u]= ",i);  
   
          for (Uint32 j = 0; j < end; j++)  
          {  
              if (j > 0 && !(j%8))  
              {  
                  fprintf(_out," ");  
              }              }
           start = theUserDefKBElement->nextElement.start;
       } // for all user def. key bindings.
  
              if (thePropertyFilter[i] & printMask)      fprintf(_out,"\n\n");
              {  
                  fprintf(_out,"1");  
              }  
              else  
              {  
                  fprintf(_out,"0");  
              }  
  
              printMask = printMask << 1;  
          }  
          fprintf(_out,"\n");  
      }  
 } }
  
 void SCMODump::dumpSCMOInstanceKeyBindings(SCMOInstance& testInst) const  void SCMODump::_dumpSCMBMgmt_Header(SCMBMgmt_Header& header,char* base) const
 { {
     SCMBInstance_Main* insthdr = testInst.inst.hdr;      fprintf(_out,"\nThe Management Header:");
     char* instbase = testInst.inst.base;      // The magic number
       fprintf(_out,"\n   magic=%08X",header.magic);
     // create a pointer to keybinding node array of the class.      // Total size of the memory block( # bytes )
     Uint64 idx = insthdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;      fprintf(_out,"\n   totalSize=%llu",header.totalSize);
     SCMBKeyBindingNode* theClassKeyBindNodeArray =      // Free bytes in the block
         (SCMBKeyBindingNode*)&((insthdr->theClass->cls.base)[idx]);      fprintf(_out,"\n   freeBytes=%llu",header.freeBytes);
       // Index to the start of the free space in this SCMB memory block.
     SCMBKeyBindingValue* ptr =      fprintf(_out,"\n   startOfFreeSpace=%llu",header.startOfFreeSpace);
         (SCMBKeyBindingValue*)      // Number of external references in this instance.
              _resolveDataPtr(insthdr->keyBindingArray,instbase);      fprintf(_out,"\n   numberExtRef=%u",header.numberExtRef);
       // Size of external reference index array;
     fprintf(_out,"\n\nInstance Key Bindings :");      fprintf(_out,"\n   sizeExtRefIndexArray=%u",header.sizeExtRefIndexArray);
     fprintf(_out,"\n=======================");  
     fprintf(_out,"\n\nNumber of Key Bindings : %u",insthdr->numberKeyBindings);      if (header.numberExtRef > 0)
       {
           fprintf(_out,"\n   extRefIndexArray=[");
           Uint64* extRefIndexArray =
               (Uint64*)&(base[header.extRefIndexArray.start]);
  
     for (Uint32 i = 0, k = insthdr->numberKeyBindings; i < k; i++)          for (Uint32 i = 0; i < header.numberExtRef;)
     {     {
         if (ptr[i].isSet)              fprintf(_out,"%llu",extRefIndexArray[i]);
               i++;
               if (i != header.numberExtRef)
         {         {
             fprintf(_out,"\n\nNo %u : '%s'",i,                  fprintf(_out,", ");
                 (const char*)printUnionValue(              }
                     theClassKeyBindNodeArray[i].type,          }
                     ptr[i].data,          fprintf(_out,"\n");
                     instbase).getCString());  
         }         }
         else         else
         {         {
             fprintf(_out,"\n\nNo %u : Not Set",i);             fprintf(_out,"\n   extRefIndexArray=[NO INDEX]\n");
   
         }         }
     }     }
     fprintf(_out,"\n");  
 }  
  
 void SCMODump::dumpSCMOClass(SCMOClass& testCls) const  void SCMODump::dumpSCMOClass(SCMOClass& testCls, Boolean inclMemHdr) const
 { {
     SCMBClass_Main* clshdr = testCls.cls.hdr;     SCMBClass_Main* clshdr = testCls.cls.hdr;
     char* clsbase = testCls.cls.base;     char* clsbase = testCls.cls.base;
  
     fprintf(_out,"\n\nDump of SCMOClass\n");     fprintf(_out,"\n\nDump of SCMOClass\n");
     // The magic number for SCMO class  
     fprintf(_out,"\nheader.magic=%08X",clshdr->header.magic);      if (inclMemHdr)
     // Total size of the instance memory block( # bytes )      {
     fprintf(_out,"\nheader.totalSize=%llu",clshdr->header.totalSize);          _dumpSCMBMgmt_Header(clshdr->header,clsbase);
       }
   
     // The reference counter for this c++ class     // The reference counter for this c++ class
     fprintf(_out,"\nrefCount=%i",clshdr->refCount.get());     fprintf(_out,"\nrefCount=%i",clshdr->refCount.get());
       fprintf(_out,"\n\nThe Flags:");
       fprintf(_out,"\n   isEmpty: %s",
              (clshdr->flags.isEmpty ? "True" : "False"));
     fprintf(_out,"\n\nsuperClassName: \'%s\'",     fprintf(_out,"\n\nsuperClassName: \'%s\'",
            NULLSTR(_getCharString(clshdr->superClassName,clsbase)));            NULLSTR(_getCharString(clshdr->superClassName,clsbase)));
     fprintf(_out,"\nnameSpace: \'%s\'",     fprintf(_out,"\nnameSpace: \'%s\'",
Line 4649 
Line 5555 
  
 void SCMODump::hexDumpSCMOClass(SCMOClass& testCls) const void SCMODump::hexDumpSCMOClass(SCMOClass& testCls) const
 { {
     char* tmp;  
   
     SCMBClass_Main* clshdr = testCls.cls.hdr;     SCMBClass_Main* clshdr = testCls.cls.hdr;
     char* clsbase = testCls.cls.base;     char* clsbase = testCls.cls.base;
  
Line 4680 
Line 5584 
         }         }
         else         else
         {         {
             line = clshdr->propertySet.number%16;              line = clshdr->propertySet.number & 15;
         }         }
  
  
Line 4705 
Line 5609 
 void SCMODump::dumpKeyBindingSet(SCMOClass& testCls) const void SCMODump::dumpKeyBindingSet(SCMOClass& testCls) const
 { {
     SCMBClass_Main* clshdr = testCls.cls.hdr;     SCMBClass_Main* clshdr = testCls.cls.hdr;
     char* clsbase = testCls.cls.base;  
  
     fprintf(_out,"\n\nKey Binding Set:");     fprintf(_out,"\n\nKey Binding Set:");
     fprintf(_out,"\n=================\n");     fprintf(_out,"\n=================\n");
Line 4748 
Line 5651 
  
         fprintf(_out,"\nHash Tag %3u Hash Index %3u",         fprintf(_out,"\nHash Tag %3u Hash Index %3u",
                nodeArray[i].nameHashTag,                nodeArray[i].nameHashTag,
                nodeArray[i].nameHashTag%PEGASUS_KEYBINDIG_SCMB_HASHSIZE);                 nodeArray[i].nameHashTag & (PEGASUS_KEYBINDIG_SCMB_HASHSIZE -1));
  
         fprintf(_out,"\nType: %s",cimTypeToString(nodeArray[i].type));         fprintf(_out,"\nType: %s",cimTypeToString(nodeArray[i].type));
  
Line 4759 
Line 5662 
 void SCMODump::dumpClassProperties(SCMOClass& testCls) const void SCMODump::dumpClassProperties(SCMOClass& testCls) const
 { {
     SCMBClass_Main* clshdr = testCls.cls.hdr;     SCMBClass_Main* clshdr = testCls.cls.hdr;
     char* clsbase = testCls.cls.base;  
  
     fprintf(_out,"\n\nClass Properties:");     fprintf(_out,"\n\nClass Properties:");
     fprintf(_out,"\n=================\n");     fprintf(_out,"\n=================\n");
Line 4809 
Line 5711 
  
     fprintf(_out,"\nHash Tag %3u Hash Index %3u",     fprintf(_out,"\nHash Tag %3u Hash Index %3u",
            prop.nameHashTag,            prop.nameHashTag,
            prop.nameHashTag%PEGASUS_PROPERTY_SCMB_HASHSIZE);             prop.nameHashTag & (PEGASUS_PROPERTY_SCMB_HASHSIZE -1));
     fprintf(_out,"\nPropagated: %s isKey: %s",     fprintf(_out,"\nPropagated: %s isKey: %s",
            (prop.flags.propagated?"TRUE":"FALSE"),            (prop.flags.propagated?"TRUE":"FALSE"),
            (prop.flags.isKey?"TRUE":"FALSE")            (prop.flags.isKey?"TRUE":"FALSE")
Line 4843 
Line 5745 
         }         }
         else         else
         {         {
             line = size%16;              line = size & 15;
         }         }
  
  
Line 4908 
Line 5810 
  
 void SCMODump::printSCMOValue( void SCMODump::printSCMOValue(
     const SCMBValue& theValue,     const SCMBValue& theValue,
     char* base) const      char* base,
       Boolean verbose) const
 { {
    fprintf(_out,"\nValueType : %s",cimTypeToString(theValue.valueType));    fprintf(_out,"\nValueType : %s",cimTypeToString(theValue.valueType));
    fprintf(_out,"\nValue was set: %s",    fprintf(_out,"\nValue was set: %s",
Line 4920 
Line 5823 
    }    }
    if (theValue.flags.isArray)    if (theValue.flags.isArray)
    {    {
        fprintf(_out,         fprintf(
              _out,
                "\nThe value is an Array of size: %u",                "\nThe value is an Array of size: %u",
                theValue.valueArraySize);                theValue.valueArraySize);
        fprintf(_out,"\nThe values are: %s",         printArrayValue(
               (const char*)printArrayValue(  
                   theValue.valueType,                   theValue.valueType,
                   theValue.valueArraySize,                   theValue.valueArraySize,
                   theValue.value,                   theValue.value,
                   base).getCString());             base,
              verbose);
    }    }
    else    else
    {    {
       fprintf(_out,"\nThe Value is: '%s'",         printUnionValue(theValue.valueType,theValue.value,base,verbose);
           (const char*)  
              printUnionValue(theValue.valueType,theValue.value,base)  
              .getCString());  
    }    }
  
    return;    return;
Line 4962 
Line 5863 
          }          }
          else          else
          {          {
              end = noProperties%64;               end = noProperties & 63;
          }          }
  
          fprintf(_out,"\nkeyPropertyMask[%02u]= ",i);          fprintf(_out,"\nkeyPropertyMask[%02u]= ",i);
  
          for (Uint32 j = 0; j < end; j++)          for (Uint32 j = 0; j < end; j++)
          {          {
              if (j > 0 && !(j%8))               if (j > 0 && !(j & 7))
              {              {
                  fprintf(_out," ");                  fprintf(_out," ");
              }              }
Line 4989 
Line 5890 
      }      }
 } }
  
 void SCMODump::_hexDump(char* buffer,int length) const  void SCMODump::_hexDump(char* buffer,Uint64 length) const
 { {
  
     unsigned char printLine[3][80];     unsigned char printLine[3][80];
Line 4997 
Line 5898 
     int len;     int len;
     unsigned char item;     unsigned char item;
  
     for (int i = 0; i < length;i=i+1)      for (Uint64 i = 0; i < length;i=i+1)
     {     {
         p = i%80;          p = (int)i%80;
  
         if ((p == 0 && i > 0) || i == length-1 )         if ((p == 0 && i > 0) || i == length-1 )
         {         {
Line 5040 
Line 5941 
         }         }
  
         printLine[1][p] = item/16;         printLine[1][p] = item/16;
         printLine[2][p] = item%16;          printLine[2][p] = item & 15;
  
     }     }
 } }
  
 String SCMODump::printArrayValue(  void SCMODump::printArrayValue(
     CIMType type,     CIMType type,
     Uint32 size,     Uint32 size,
     SCMBUnion u,     SCMBUnion u,
     char* base) const      char* base,
       Boolean verbose) const
 { {
     Buffer out;     Buffer out;
  
Line 5070 
Line 5972 
                           STRLIT("FALSE)"));                           STRLIT("FALSE)"));
                 out.append(';');                 out.append(';');
             }             }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
Line 5085 
Line 5988 
                           STRLIT("FALSE)"));                           STRLIT("FALSE)"));
                 out.append(';');                 out.append(';');
             }             }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
Line 5100 
Line 6004 
                           STRLIT("FALSE)"));                           STRLIT("FALSE)"));
                 out.append(';');                 out.append(';');
             }             }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
Line 5115 
Line 6020 
                           STRLIT("FALSE)"));                           STRLIT("FALSE)"));
                 out.append(';');                 out.append(';');
             }             }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
Line 5130 
Line 6036 
                           STRLIT("FALSE)"));                           STRLIT("FALSE)"));
                 out.append(';');                 out.append(';');
             }             }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
Line 5145 
Line 6052 
                           STRLIT("FALSE)"));                           STRLIT("FALSE)"));
                 out.append(';');                 out.append(';');
             }             }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
Line 5160 
Line 6068 
                           STRLIT("FALSE)"));                           STRLIT("FALSE)"));
                 out.append(';');                 out.append(';');
             }             }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
Line 5175 
Line 6084 
                           STRLIT("FALSE)"));                           STRLIT("FALSE)"));
                 out.append(';');                 out.append(';');
             }             }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
Line 5190 
Line 6100 
                           STRLIT("FALSE)"));                           STRLIT("FALSE)"));
                 out.append(';');                 out.append(';');
             }             }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
Line 5205 
Line 6116 
                           STRLIT("FALSE)"));                           STRLIT("FALSE)"));
                 out.append(';');                 out.append(';');
             }             }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
Line 5220 
Line 6132 
                           STRLIT("FALSE)"));                           STRLIT("FALSE)"));
                 out.append(';');                 out.append(';');
             }             }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
Line 5235 
Line 6148 
                           STRLIT("FALSE)"));                           STRLIT("FALSE)"));
                 out.append(';');                 out.append(';');
             }             }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_STRING:     case CIMTYPE_STRING:
         {         {
             SCMBDataPtr* p = (SCMBDataPtr*)&(base[u.arrayValue.start]);  
             for (Uint32 i = 0; i < size; i++)             for (Uint32 i = 0; i < size; i++)
             {             {
                 if ( 0 != p[i].length)                  if ( 0 != p[i].stringValue.size)
                 {                 {
                     out.append('\'');                     out.append('\'');
                     out.append((const char*)_getCharString(p[i],base),                      out.append(
                                p[i].length-1);                          (const char*)_getCharString(p[i].stringValue,base),
                           p[i].stringValue.size-1);
                     out.append('\'');                     out.append('\'');
                 }                 }
                 else                 else
Line 5256 
Line 6170 
                 }                 }
                 out.append(';');                 out.append(';');
             }             }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_DATETIME:     case CIMTYPE_DATETIME:
         {         {
             SCMBDateTime* p = (SCMBDateTime*)&(base[u.arrayValue.start]);  
             CIMDateTime x;             CIMDateTime x;
             for (Uint32 i = 0; i < size; i++)             for (Uint32 i = 0; i < size; i++)
             {             {
                 memcpy(x._rep,&(p[i]),sizeof(SCMBDateTime));                  memcpy(x._rep,&(p[i].dateTimeValue),sizeof(SCMBDateTime));
                 _toString(out,x);                 _toString(out,x);
                 out.append(' ');                 out.append(' ');
             }             }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
Line 5276 
Line 6191 
     case CIMTYPE_OBJECT:     case CIMTYPE_OBJECT:
     case CIMTYPE_INSTANCE:     case CIMTYPE_INSTANCE:
         {         {
             // TODO: has to dump SCMOInstance ...              if (verbose)
               {
                   for (Uint32 i = 0; i < size; i++)
                   {
                       fprintf(_out,"\n-----------> "
                                     "Start of embedded external reference [%d]"
                                     " <-----------\n\n",i);
                       dumpSCMOInstance(*(p[i].extRefPtr));
                       fprintf(_out,"\n-----------> "
                                     "End of embedded external reference [%d]"
                                     " <-----------\n\n",i);
                   }
   
               } else
               {
                   fprintf(_out,"\nThe values are: ");
   
                   for (Uint32 i = 0; i < size; i++)
                   {
                       fprintf(
                           _out,
                           "Pointer to external Reference[%d] : \'%p\';",
                           i,p[i].extRefPtr);
                   }
               }
   
             break;             break;
   
         }         }
     default:     default:
         {         {
Line 5286 
Line 6227 
         }         }
     }     }
  
     return out.getData();      return;
 } }
  
 String SCMODump::printUnionValue(  void SCMODump::printUnionValue(
     CIMType type,     CIMType type,
     SCMBUnion u,     SCMBUnion u,
     char* base) const      char* base,
       Boolean verbose) const
 { {
  
     Buffer out;     Buffer out;
Line 5302 
Line 6244 
     case CIMTYPE_BOOLEAN:     case CIMTYPE_BOOLEAN:
         {         {
             _toString(out,u.simple.val.bin);             _toString(out,u.simple.val.bin);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_UINT8:     case CIMTYPE_UINT8:
         {         {
             _toString(out,u.simple.val.u8);             _toString(out,u.simple.val.u8);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_SINT8:     case CIMTYPE_SINT8:
         {         {
             _toString(out,u.simple.val.s8);             _toString(out,u.simple.val.s8);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_UINT16:     case CIMTYPE_UINT16:
         {         {
             _toString(out,(Uint32)u.simple.val.u16);             _toString(out,(Uint32)u.simple.val.u16);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_SINT16:     case CIMTYPE_SINT16:
         {         {
             _toString(out,u.simple.val.s16);             _toString(out,u.simple.val.s16);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_UINT32:     case CIMTYPE_UINT32:
         {         {
             _toString(out,u.simple.val.u32);             _toString(out,u.simple.val.u32);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_SINT32:     case CIMTYPE_SINT32:
         {         {
             _toString(out,u.simple.val.s32);             _toString(out,u.simple.val.s32);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_UINT64:     case CIMTYPE_UINT64:
         {         {
             _toString(out,u.simple.val.u64);             _toString(out,u.simple.val.u64);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_SINT64:     case CIMTYPE_SINT64:
         {         {
             _toString(out,u.simple.val.s64);             _toString(out,u.simple.val.s64);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_REAL32:     case CIMTYPE_REAL32:
         {         {
             _toString(out,u.simple.val.r32);             _toString(out,u.simple.val.r32);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_REAL64:     case CIMTYPE_REAL64:
         {         {
             _toString(out,u.simple.val.r32);             _toString(out,u.simple.val.r32);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_CHAR16:     case CIMTYPE_CHAR16:
         {         {
             _toString(out,u.simple.val.c16);             _toString(out,u.simple.val.c16);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_STRING:     case CIMTYPE_STRING:
         {         {
             if ( 0 != u.stringValue.length)              if ( 0 != u.stringValue.size)
             {             {
                 out.append((const char*)_getCharString(u.stringValue,base),                 out.append((const char*)_getCharString(u.stringValue,base),
                            u.stringValue.length-1);                             u.stringValue.size-1);
             }             }
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
Line 5386 
Line 6341 
             CIMDateTime x;             CIMDateTime x;
             memcpy(x._rep,&(u.dateTimeValue),sizeof(SCMBDateTime));             memcpy(x._rep,&(u.dateTimeValue),sizeof(SCMBDateTime));
             _toString(out,x);             _toString(out,x);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
Line 5393 
Line 6349 
     case CIMTYPE_OBJECT:     case CIMTYPE_OBJECT:
     case CIMTYPE_INSTANCE:     case CIMTYPE_INSTANCE:
         {         {
             // TODO: Has to dump SCMOInstance.              if (verbose)
               {
                   fprintf(_out,"\n-----------> "
                                 "Start of embedded external reference"
                                 " <-----------\n\n");
                   dumpSCMOInstance(*u.extRefPtr);
                   fprintf(_out,"\n-----------> "
                                "End of embedded external reference"
                                " <-----------\n\n");
               } else
               {
                   fprintf(
                       _out,
                       "Pointer to external Reference : \'%p\'",
                       u.extRefPtr);
               }
   
             break;             break;
         }         }
     default:     default:
Line 5403 
Line 6375 
         }         }
     }     }
  
   return out.getData();    return;
 } }
   #endif // PEGASUS_DEBUG (class SCMODump only in debug builds available)
  
  
 /***************************************************************************** /*****************************************************************************
  * The constant functions  * The constant functions
  *****************************************************************************/  *****************************************************************************/
  
 static Boolean _equalUTF8Strings(  #ifdef PEGASUS_HAS_ICU
     const SCMBDataPtr& ptr_a,  Uint32 _utf8ICUncasecmp(
     char* base,      const char* a,
     const char* name,      const char* b,
     Uint32 len)     Uint32 len)
   
 { {
     // size without trailing '\0' !!      UErrorCode errorCode=U_ZERO_ERROR;
     if (ptr_a.length-1 != len)  
     {  
         return false;  
     }  
     const char* a = (const char*)_getCharString(ptr_a,base);  
  
     // lets do a loop-unrolling optimized compare here      Uint32 rc, a16len,b16len,utf16BufLen;
     while (len >= 8)      utf16BufLen = (len*sizeof(UChar))+2;
     {  
         if ((a[0] - name[0]) || (a[1] - name[1]) ||  
             (a[2] - name[2]) || (a[3] - name[3]) ||  
             (a[4] - name[4]) || (a[5] - name[5]) ||  
             (a[6] - name[6]) || (a[7] - name[7]))  
         {  
             return false;  
         }  
         len -= 8;  
         a += 8;  
         name += 8;  
     }  
     while (len >= 4)  
     {  
         if ((a[0] - name[0]) || (a[1] - name[1]) ||  
             (a[2] - name[2]) || (a[3] - name[3]))  
         {  
             return false;  
         }  
         len -= 4;  
         a += 4;  
         name += 4;  
     }  
     while (len--)  
     {  
         if (a[0] - name[0])  
         {  
             return false;  
         }  
         a++;  
         name++;  
     }  
     return true;  
 }  
  
       UChar* a_UTF16 = (UChar*)malloc(utf16BufLen);
       UChar* b_UTF16 = (UChar*)malloc(utf16BufLen);
  
 static Boolean _equalNoCaseUTF8Strings(      UConverter *conv = ucnv_open(0, &errorCode);
     const SCMBDataPtr& ptr_a,      if(U_FAILURE(errorCode))
     char* base,      {
     const char* name,          free(a_UTF16);
     Uint32 len)          free(b_UTF16);
           String message("SCMO::_utf8ICUncasecmp() ICUError: ");
           message.append(u_errorName(errorCode));
           message.append(" Can not open ICU default converter!");
           throw CIMException(CIM_ERR_FAILED,message );
       }
  
 {      a16len = ucnv_toUChars(conv,a_UTF16,utf16BufLen,a,len,&errorCode);
  
     //both are empty strings, so they are equal.      if(U_FAILURE(errorCode))
     if (ptr_a.length == 0 && len == 0)  
     {     {
         return true;          free(a_UTF16);
           free(b_UTF16);
           ucnv_close(conv);
           String message("SCMO::_utf8ICUncasecmp() ICUError: ");
           message.append(u_errorName(errorCode));
           message.append(" Can not convert string a:'");
           message.append(String(a,len));
           message.append('\'');
           throw CIMException(CIM_ERR_FAILED,message );
     }     }
  
     // size without trailing '\0' !!      b16len = ucnv_toUChars(conv,b_UTF16,utf16BufLen,b,len,&errorCode);
     if (ptr_a.length-1 != len)  
       if(U_FAILURE(errorCode))
     {     {
         return false;          free(a_UTF16);
           free(b_UTF16);
           ucnv_close(conv);
           String message("SCMO::_utf8ICUncasecmp() ICUError: ");
           message.append(u_errorName(errorCode));
           message.append(" Can not convert string b:'");
           message.append(String(b,len));
           message.append('\'');
           throw CIMException(CIM_ERR_FAILED,message );
     }     }
  
     const char* a = (const char*)_getCharString(ptr_a,base);      rc = u_strCaseCompare(
           a_UTF16,a16len,
           b_UTF16,b16len,
           U_FOLD_CASE_DEFAULT,
           &errorCode);
   
       if(U_FAILURE(errorCode))
       {
           free(a_UTF16);
           free(b_UTF16);
           ucnv_close(conv);
           String message("SCMO::_utf8ICUncasecmp() ICUError: ");
           message.append(u_errorName(errorCode));
           message.append(" Can not compare string a:'");
           message.append(String(a,len));
           message.append("' with b: '");
           message.append(String(b,len));
           message.append('\'');
           throw CIMException(CIM_ERR_FAILED,message );
       }
  
     // ToDo: Here an UTF8 complinet comparison should take place      free(a_UTF16);
     return ( strncasecmp(a,name,len )== 0 );      free(b_UTF16);
       ucnv_close(conv);
  
       return(rc);
 } }
   #endif
  
 /** /**
  * This function calcutates a free memory slot in the single chunk memory block.  * This function calcutates a free memory slot in the single chunk memory block.
Line 5504 
Line 6481 
  *            e.g. &cls.mem  *            e.g. &cls.mem
  * @return The relaive index of the free memory slot.  * @return The relaive index of the free memory slot.
  */  */
   Uint64 _getFreeSpace(
 static Uint64 _getFreeSpace(  
     SCMBDataPtr& ptr,     SCMBDataPtr& ptr,
     Uint64 size,      Uint32 size,
     SCMBMgmt_Header** pmem,      SCMBMgmt_Header** pmem)
     Boolean clear)  
 { {
     Uint64 oldSize, start;     Uint64 oldSize, start;
       Uint64 alignedStart, reqAlignSize;
  
     if (size == 0)     if (size == 0)
     {     {
         ptr.start = 0;         ptr.start = 0;
         ptr.length = 0;          ptr.size = 0;
         return 0;         return 0;
     }     }
  
     // The SCMBDataPtr has to be set before any reallocation.     // The SCMBDataPtr has to be set before any reallocation.
     start = (*pmem)->startOfFreeSpace;     start = (*pmem)->startOfFreeSpace;
     ptr.start = start;  
     ptr.length = size;  
  
     while ((*pmem)->freeBytes < size)      // Need to align the start of freespace to 8 byte
       // boundaries to avoid alignment issues on some architectures
       // Round up to nearest multiple of 8
       alignedStart = (start + 7) & ~7;
       // due to the alignment, a little more room is needed in the SCMB
       reqAlignSize = (size + alignedStart - start);
   
       ptr.start = alignedStart;
       ptr.size = size;
       // add 8 bytes of size for later alignment on the next pointer
       while ((*pmem)->freeBytes < reqAlignSize)
     {     {
         // save old size of buffer         // save old size of buffer
         oldSize = (*pmem)->totalSize;         oldSize = (*pmem)->totalSize;
         // reallocate the buffer, double the space !         // reallocate the buffer, double the space !
         // This is a working approach until a better algorithm is found.         // This is a working approach until a better algorithm is found.
         (*pmem) = (SCMBMgmt_Header*)realloc((*pmem),oldSize*2);          void* newBlockPtr = realloc((*pmem),(size_t)oldSize*2);
         if ((*pmem) == 0)          if ((newBlockPtr) == 0)
         {         {
             // Not enough memory!             // Not enough memory!
             throw PEGASUS_STD(bad_alloc)();             throw PEGASUS_STD(bad_alloc)();
         }         }
           (*pmem) = (SCMBMgmt_Header*)newBlockPtr;
         // increase the total size and free space         // increase the total size and free space
         (*pmem)->freeBytes+=oldSize;         (*pmem)->freeBytes+=oldSize;
         (*pmem)->totalSize+=oldSize;         (*pmem)->totalSize+=oldSize;
     }     }
  
     (*pmem)->freeBytes -= size;      (*pmem)->freeBytes -= reqAlignSize;
     (*pmem)->startOfFreeSpace += size;      (*pmem)->startOfFreeSpace = alignedStart + size;
  
     if (clear)      // Init memory from unaligned start up to the size required with alignment
     {      // to zero.
         // If requested, set memory to 0.      memset(&((char*)(*pmem))[start],0,(size_t)reqAlignSize);
         memset(&((char*)(*pmem))[start],0,size);      PEGASUS_DEBUG_ASSERT(
     }          ((*pmem)->freeBytes+(*pmem)->startOfFreeSpace) == (*pmem)->totalSize);
     return start;  
       return alignedStart;
 } }
  
 static void _setString(  void _setString(
     const String& theString,     const String& theString,
     SCMBDataPtr& ptr,     SCMBDataPtr& ptr,
     SCMBMgmt_Header** pmem)     SCMBMgmt_Header** pmem)
Line 5564 
Line 6550 
     // Get the real size of the UTF8 sting + \0.     // Get the real size of the UTF8 sting + \0.
     // It maybe greater then the length in the String due to     // It maybe greater then the length in the String due to
     // 4 byte encoding of non ASCII chars.     // 4 byte encoding of non ASCII chars.
     Uint64 start,length = strlen((const char*)theCString)+1;      Uint64 start;
       Uint32 length = strlen((const char*)theCString)+1;
  
     // If the string is not empty.     // If the string is not empty.
     if (length != 1)     if (length != 1)
Line 5580 
Line 6567 
     else     else
     {     {
         ptr.start = 0;         ptr.start = 0;
         ptr.length = 0;          ptr.size = 0;
     }     }
 } }
  
 static void _setBinary(  void _setBinary(
     const void* theBuffer,     const void* theBuffer,
     Uint64 bufferSize,      Uint32 bufferSize,
     SCMBDataPtr& ptr,     SCMBDataPtr& ptr,
     SCMBMgmt_Header** pmem)     SCMBMgmt_Header** pmem)
 { {
  
     // If buffer is not empty.     // If buffer is not empty.
     if (bufferSize != 1 && theBuffer != 0)      if (bufferSize != 0 && theBuffer != 0)
     {     {
  
         Uint64 start;         Uint64 start;
Line 5609 
Line 6596 
     else     else
     {     {
         ptr.start = 0;         ptr.start = 0;
         ptr.length = 0;          ptr.size = 0;
       }
   }
   
   void _destroyExternalReferencesInternal(SCMBMgmt_Header* memHdr)
   {
   
       Uint32 number = memHdr->numberExtRef;
   
       if (0 != number)
       {
           char * base = ((char*)memHdr);
           Uint64* array =
               (Uint64*)&(base[memHdr->extRefIndexArray.start]);
           for (Uint32 i = 0; i < number; i++)
           {
                delete ((SCMBUnion*)(&(base[array[i]])))->extRefPtr;
           }
   
     }     }
 } }
  


Legend:
Removed from v.1.2.2.33  
changed lines
  Added in v.1.24

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2