当前位置: 首页>>代码示例>>C++>>正文


C++ OSArray::release方法代码示例

本文整理汇总了C++中OSArray::release方法的典型用法代码示例。如果您正苦于以下问题:C++ OSArray::release方法的具体用法?C++ OSArray::release怎么用?C++ OSArray::release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OSArray的用法示例。


在下文中一共展示了OSArray::release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: removePersonalities

bool IOCatalogue::removePersonalities(OSArray * personalitiesToRemove)
{
    bool                   result           = true;
    OSArray              * arrayCopy        = NULL;  // do not release
    OSCollectionIterator * iterator         = NULL;  // must release
    OSDictionary         * personality      = NULL;  // do not release
    OSDictionary         * checkPersonality = NULL;  // do not release
    unsigned int           count, i;

    // remove configs from catalog.

    arrayCopy = OSArray::withArray(array);
    if (!arrayCopy) {
        result = false;
        goto finish;
    }

    iterator = OSCollectionIterator::withCollection(arrayCopy);
    arrayCopy->release();
    if (!iterator) {
        result = false;
        goto finish;
    }

    array->flushCollection();

    count = personalitiesToRemove->getCount();

    /* Go through the old catalog's list of personalities and add back any that
     * are *not* found in 'personalitiesToRemove'.
     */
    while ((personality = (OSDictionary *)iterator->getNextObject())) {
        bool found = false;

        for (i = 0; i < count; i++) {
            checkPersonality = OSDynamicCast(OSDictionary,
                                             personalitiesToRemove->getObject(i));

            /* Do isEqualTo() with the single-arg version to make an exact
             * comparison (unlike _removeDrivers() above).
             */
            if (personality->isEqualTo(checkPersonality)) {
                found = true;
                break;
            }
        }

        if (!found) {
            array->setObject(personality);
        }
    }

finish:

    OSSafeRelease(iterator);
    return result;
}
开发者ID:,项目名称:,代码行数:57,代码来源:

示例2: addAvailableSelection

// <rdar://8202424>
IOReturn IOAudioSelectorControl::addAvailableSelection(SInt32 selectionValue, OSString *selectionDescription, const char* tagName, OSObject* tag)
{
	OSArray *newSelections;
	OSArray *oldAvailableSelections;
    IOReturn result = kIOReturnSuccess;
    
	oldAvailableSelections = availableSelections;
	newSelections = OSArray::withArray(availableSelections);
	if (!newSelections)
		return kIOReturnNoMemory;

    if (selectionDescription == NULL) {
        result = kIOReturnBadArgument;
    } else {
        if (valueExists(selectionValue)) {
            result = kIOReturnError;
        } else {
            OSDictionary *newSelection;
            
            newSelection = OSDictionary::withCapacity(2);
            
            if (newSelection) {
                OSNumber *number;
				
                number = OSNumber::withNumber(selectionValue, sizeof(SInt32)*8);
                
                if (number) {
                    newSelection->setObject(kIOAudioSelectorControlSelectionValueKey, number);
                    newSelection->setObject(kIOAudioSelectorControlSelectionDescriptionKey, selectionDescription);
                    newSelections->setObject(newSelection);
					
                    number->release();
                } else {
                    result = kIOReturnError;
                }
				
				if ( tagName && tag ) {
					newSelection->setObject(tagName, tag);
				}
				
				availableSelections = newSelections;
				setProperty(kIOAudioSelectorControlAvailableSelectionsKey, availableSelections);
				oldAvailableSelections->release();
                
                newSelection->release();
            } else {
                result = kIOReturnError;
            }
        }
    }
    
	if (kIOReturnSuccess == result) {
		sendChangeNotification(kIOAudioControlRangeChangeNotification);
	}
	
    return result;
}
开发者ID:EMlyDinEsHMG,项目名称:IOAudioFamily-Sleep-Audio-FIx,代码行数:58,代码来源:IOAudioSelectorControl.cpp

示例3: CompareDeviceUsage

bool CompareDeviceUsage( IOService * owner, OSDictionary * matching, SInt32 * score, SInt32 increment)
{
    // We return success if we match the key in the dictionary with the key in
    // the property table, or if the prop isn't present
    //
    OSObject * 		usage;
    OSObject *		usagePage;
    OSArray *		functions;
    OSDictionary * 	pair;
    bool		matches = true;
    int			count;
    
    usage = matching->getObject( kIOHIDDeviceUsageKey );
    usagePage = matching->getObject( kIOHIDDeviceUsagePageKey );
    functions = OSDynamicCast(OSArray, owner->copyProperty( kIOHIDDeviceUsagePairsKey ));
    
    if ( functions )
    {
        if ( usagePage || usage )
        {
            count = functions->getCount();
            
            for (int i=0; i<count; i++)
            {
                if ( !(pair = (OSDictionary *)functions->getObject(i)) )
                    continue;
            
                if ( !usagePage || 
                    !(matches = usagePage->isEqualTo(pair->getObject(kIOHIDDeviceUsagePageKey))) )
                    continue;

                if ( score && !usage ) 
                {
                    *score += increment / 2;
                    break;
                }
                    
                if ( !usage || 
                    !(matches = usage->isEqualTo(pair->getObject(kIOHIDDeviceUsageKey))) )            
                    continue;
        
                if ( score ) 
                    *score += increment;
                
                break;
            }
        }
        
        functions->release();
    } else {
		matches = false;
	}
    
    return matches;
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:55,代码来源:IOHIDFamilyPrivate.cpp

示例4:

OSArray *OSArray::withCapacity(unsigned int capacity)
{
    OSArray *me = new OSArray;

    if (me && !me->initWithCapacity(capacity)) {
        me->release();
        return 0;
    }

    return me;
}
开发者ID:JackieXie168,项目名称:xnu,代码行数:11,代码来源:OSArray.cpp

示例5: while

OSCollection * OSArray::copyCollection(OSDictionary *cycleDict)
{
    bool allocDict = !cycleDict;
    OSCollection *ret = 0;
    OSArray *newArray = 0;

    if (allocDict) {
	cycleDict = OSDictionary::withCapacity(16);
	if (!cycleDict)
	    return 0;
    }

    do {
	// Check for a cycle
	ret = super::copyCollection(cycleDict);
	if (ret)
	    continue;
	
	newArray = OSArray::withArray(this);
	if (!newArray)
	    continue;

	// Insert object into cycle Dictionary
	cycleDict->setObject((const OSSymbol *) this, newArray);

	for (unsigned int i = 0; i < count; i++) {
	    OSCollection *coll =
		OSDynamicCast(OSCollection, EXT_CAST(newArray->array[i]));

	    if (coll) {
		OSCollection *newColl = coll->copyCollection(cycleDict);
		if (!newColl)
		    goto abortCopy;

		newArray->replaceObject(i, newColl);
		newColl->release();
	    };
	};

	ret = newArray;
	newArray = 0;

    } while (false);

abortCopy:
    if (newArray)
	newArray->release();

    if (allocDict)
	cycleDict->release();

    return ret;
}
开发者ID:JackieXie168,项目名称:xnu,代码行数:53,代码来源:OSArray.cpp

示例6: addPersonality

void IOCatalogue::addPersonality(OSDictionary * dict)
{
    const OSSymbol * sym;
    OSArray * arr;

    sym = OSDynamicCast(OSSymbol, dict->getObject(gIOProviderClassKey));
    if (!sym) return;
    arr = (OSArray *) personalities->getObject(sym);
    if (arr) arr->setObject(dict);
    else
    {
        arr = OSArray::withObjects((const OSObject **)&dict, 1, 2);
        personalities->setObject(sym, arr);
        arr->release();
    }
}
开发者ID:CptFrazz,项目名称:xnu,代码行数:16,代码来源:IOCatalogue.cpp

示例7: replaceAvailableSelection

IOReturn IOAudioSelectorControl::replaceAvailableSelection(SInt32 selectionValue, OSString *selectionDescription)
{
    OSCollectionIterator *iterator;
	OSArray *newSelections;
	OSArray *oldAvailableSelections;
    IOReturn result = kIOReturnSuccess;
    
    assert(availableSelections);

	oldAvailableSelections = availableSelections;
	newSelections = OSArray::withArray(availableSelections);
	if (!newSelections)
		return kIOReturnNoMemory;

    iterator = OSCollectionIterator::withCollection(newSelections);
    if (iterator) {
        OSDictionary *	selection;
		UInt32			index;

		index = 0;
        while ( (selection = (OSDictionary *)iterator->getNextObject() )) {
            OSNumber *	sValue;

            sValue = (OSNumber *)selection->getObject(kIOAudioSelectorControlSelectionValueKey);

            if (sValue && ((SInt32)sValue->unsigned32BitValue() == selectionValue)) {
				// Replace the selected dictionary in the array
				newSelections->replaceObject(index, selectionDescription);
				result = kIOReturnSuccess;
                break;
            }
			index++;
        }
		availableSelections = newSelections;
        setProperty(kIOAudioSelectorControlAvailableSelectionsKey, availableSelections);
		oldAvailableSelections->release();

        iterator->release();
    }

	if (kIOReturnSuccess == result) {
		sendChangeNotification(kIOAudioControlRangeChangeNotification);
	}

    return result;
}
开发者ID:EMlyDinEsHMG,项目名称:IOAudioFamily-Sleep-Audio-FIx,代码行数:46,代码来源:IOAudioSelectorControl.cpp

示例8: return

OSArray * OSDictionary::copyKeys(void)
{
    OSArray * array;

	array = OSArray::withCapacity(count);
	if (!array) return (0);

	for (unsigned int i = 0; i < count; i++)
	{
	    if (!array->setObject(i, dictionary[i].key))
	    {
            array->release();
            array = 0;
            break;
        }
	}
    return (array);
}
开发者ID:aglab2,项目名称:darwin-xnu,代码行数:18,代码来源:OSDictionary.cpp

示例9: _removeDrivers

static IOReturn _removeDrivers( OSArray * array, OSDictionary * matching )
{
    OSCollectionIterator * tables;
    OSDictionary         * dict;
    OSArray              * arrayCopy;
    IOReturn               ret = kIOReturnSuccess;

    // remove configs from catalog.

    arrayCopy = OSArray::withCapacity(100);
    if ( !arrayCopy )
        return kIOReturnNoMemory;

    tables = OSCollectionIterator::withCollection(arrayCopy);
    arrayCopy->release();
    if ( !tables )
        return kIOReturnNoMemory;

    arrayCopy->merge(array);
    array->flushCollection();
    tables->reset();
    while ( (dict = (OSDictionary *)tables->getNextObject()) ) {

        /* Remove from the catalogue's array any personalities
         * that match the matching dictionary.
         * This comparison must be done with only the keys in the
         * "matching" dict to enable general matching.
         */
        if ( dict->isEqualTo(matching, matching) )
            continue;

        array->setObject(dict);
    }

    tables->release();

    return ret;
}
开发者ID:,项目名称:,代码行数:38,代码来源:

示例10: load_kernel_extension

/*********************************************************************
* This is the function that IOCatalogue calls in order to load a kmod.
* It first checks whether the kmod is already loaded. If the kmod
* isn't loaded, this function builds a dependency list and calls
* load_kmod() repeatedly to guarantee that each dependency is in fact
* loaded.
*********************************************************************/
__private_extern__
kern_return_t load_kernel_extension(char * kmod_name) {
    kern_return_t result = KERN_SUCCESS;
    kmod_info_t * kmod_info = 0;  // must free
    OSArray * dependencyList = NULL;     // must release
    OSArray * curDependencyList = NULL;  // must release

   /* See if the kmod is already loaded.
    */
    kmod_info = kmod_lookupbyname_locked(kmod_name);
    if (kmod_info) {  // NOT checked
        result = KERN_SUCCESS;
        goto finish;
    }

   /* It isn't loaded; build a dependency list and
    * load those.
    */
    unsigned int count;
    unsigned int i;
    dependencyList = getDependencyListForKmod(kmod_name);
    if (!dependencyList) {
        IOLog("load_kernel_extension(): "
            "Can't get dependencies for kernel extension \"%s\".\n",
            kmod_name);
        LOG_DELAY();
        result = KERN_FAILURE;
        goto finish;
    }

    count = dependencyList->getCount();
    for (i = 0; i < count; i++) {
        kern_return_t load_result;
        OSString * curKmodName;  // don't release
        const char * cur_kmod_name;

        curKmodName = OSDynamicCast(OSString,
            dependencyList->getObject(i));
        cur_kmod_name = curKmodName->getCStringNoCopy();
        curDependencyList = getDependencyListForKmod(cur_kmod_name);
        if (!curDependencyList) {
            IOLog("load_kernel_extension(): "
                "Can't get dependencies for kernel extension \"%s\".\n",
                cur_kmod_name);
            LOG_DELAY();
            result = KERN_FAILURE;
            goto finish;
        } else {
            load_result = load_kmod(curDependencyList);
            if (load_result != KERN_SUCCESS) {
                IOLog("load_kernel_extension(): "
                    "load_kmod() failed for kmod \"%s\".\n",
                    cur_kmod_name);
                LOG_DELAY();
                result = load_result;
                goto finish;
            }
            curDependencyList->release();
            curDependencyList = NULL;
        }
    }


finish:

    if (kmod_info) {
        kfree((unsigned int)kmod_info, sizeof(kmod_info_t));
    }

    if (dependencyList) {
        dependencyList->release();
        dependencyList = NULL;
    }
    if (curDependencyList) {
        curDependencyList->release();
        curDependencyList = NULL;
    }

    return result;
}
开发者ID:OpenDarwin-CVS,项目名称:SEDarwin,代码行数:87,代码来源:kmod.cpp

示例11: testSet

void testSet()
{
    bool res = true;
    void *spaceCheck, *spaceCheck2 , *spaceCheck3;
    int i, count, count2;
    OSObject *cache[numStrCache], *str, *sym;
    OSSet *set1, *set2;
    OSArray *array;

    // Do first test without memory leak tests to initialise the metaclass
    set1 = OSSet::withCapacity(1);
    TEST_ASSERT('S', "0a", set1);
    if (set1)
        set1->release();

    // Grow the symbol pool to maximum
    for (i = 0; i < numStrCache; i++)
        cache[i] = (OSObject *) OSSymbol::withCStringNoCopy(strCache[i]);
    for (i = 0; i < numStrCache; i++)
        cache[i]->release();

    // Create and destroy an set
    spaceCheck = checkPointSpace();
    set1 = OSSet::withCapacity(1);
    TEST_ASSERT('S', "1a", set1);
    if (set1) {
        TEST_ASSERT('S', "1b", !set1->getCount());
        TEST_ASSERT('S', "1c", 1 == set1->getCapacity());
        TEST_ASSERT('S', "1d", 1 == set1->getCapacityIncrement());
        TEST_ASSERT('S', "1e", 4 == set1->setCapacityIncrement(4));
        TEST_ASSERT('S', "1f", 4 == set1->getCapacityIncrement());
        TEST_ASSERT('S', "1g", 8 == set1->ensureCapacity(5));

        spaceCheck2 = checkPointSpace();
        cache[0] = IOString::withCStringNoCopy(strCache[0]);

        spaceCheck3 = checkPointSpace();
        TEST_ASSERT('S', "1h", set1->setObject(cache[0]));
        TEST_ASSERT('S', "1i", set1->containsObject(cache[0]));
        TEST_ASSERT('S', "1j", cache[0] == set1->getAnyObject());
        cache[0]->release();
        res = res && checkSpace("(S)1k", spaceCheck3, 0);

        TEST_ASSERT('S', "1l", 1 == set1->getCount());
        set1->flushCollection();
        TEST_ASSERT('S', "1m", !set1->getCount());
        res = res && checkSpace("(S)1n", spaceCheck2, 0);

        set1->release();
    }
    res = res && checkSpace("(S)1", spaceCheck, 0);

    // Check the creation of a sizable OSSet from an set of IOObjects
    // Also check member test of set.
    spaceCheck = checkPointSpace();
    for (i = 0; i < numStrCache; i++)
        cache[i] = OSString::withCStringNoCopy(strCache[i]);
    set1 = OSSet::withObjects(cache, numStrCache, numStrCache);
    TEST_ASSERT('S', "2a", set1);
    for (i = 0; i < numStrCache; i++)
        cache[i]->release();
    if (set1) {
        TEST_ASSERT('S', "2b", numStrCache == (int) set1->getCount());
        TEST_ASSERT('S', "2c", numStrCache == (int) set1->getCapacity());
        TEST_ASSERT('S', "2d",
                    numStrCache == (int) set1->getCapacityIncrement());

        count = 0;
        for (i = set1->getCount(); --i >= 0; )
            count += set1->member(cache[i]);

        TEST_ASSERT('S', "2e", numStrCache == count);
        set1->release();
    }
    res = res && checkSpace("(S)2", spaceCheck, 0);

    // Test set creation from another set by both the setObject method
    // and the withArray factory.  And test __takeObject code first
    // with tail removal then with head removal
    spaceCheck = checkPointSpace();
    for (i = 0; i < numStrCache; i++)
        cache[i] = OSString::withCStringNoCopy(strCache[i]);
    set1 = OSSet::withObjects(cache, numStrCache, numStrCache);
    TEST_ASSERT('S', "3a", set1);
    for (i = 0; i < numStrCache; i++)
        cache[i]->release();
    set2 = 0;
    if (set1) {
        set2 = OSSet::withCapacity(set1->getCount());
        TEST_ASSERT('S', "3b", set2);
        TEST_ASSERT('S', "3c", !set2->getCount());
        TEST_ASSERT('S', "3d", set2->setObject(set1));
        TEST_ASSERT('S', "3e", set1->getCount() == set2->getCount());
    }
    if (set2) {
        TEST_ASSERT('S', "3f", numStrCache == (int) set2->getCount());
        count = count2 = 0;
        while ( (str = set2->getAnyObject()) ) {
            count  += set2->__takeObject(str);
            count2 += set1->member(str);
//.........这里部分代码省略.........
开发者ID:JackieXie168,项目名称:xnu,代码行数:101,代码来源:TestCollections.cpp

示例12: findDevices

bool ACPIBacklightPanel::findDevices(IOService * provider)
{
    DbgLog("%s::%s()\n", this->getName(),__FUNCTION__);
    
    if (!gpuDevice || !backLightDevice)
    {
        IOACPIPlatformDevice * dev = OSDynamicCast(IOACPIPlatformDevice, provider);
        if (hasBacklightMethods(dev))
        {
            DbgLog("%s: PNLF has backlight Methods\n", this->getName());
            backLightDevice = dev;
            gpuDevice = dev;
            gpuDevice->retain();
            backLightDevice->retain();
        }
        else
        {            
            gpuDevice = getGPU();
            
            if (NULL == gpuDevice)
                return false;
            
            gpuDevice->retain();
            
            if (hasBacklightMethods(gpuDevice))
            {
                backLightDevice = gpuDevice;
            }
            else
            {
                backLightDevice = getChildWithBacklightMethods(gpuDevice);
            }
            
            if (backLightDevice == NULL)
                return false;
            
            backLightDevice->retain();
        }

#ifdef DEBUG
        if (gpuDevice != backLightDevice)
        {
            OSArray * devicePaths = OSArray::withCapacity(2);
            OSString* path = getACPIPath(gpuDevice);
            IOLog("ACPIBacklight: ACPI Method _DOS found. Device path: %s\n", path->getCStringNoCopy());
            devicePaths->setObject(path);
            path->release();
            path = getACPIPath(backLightDevice);
            IOLog("ACPIBacklight: ACPI Methods _BCL _BCM _BQC found. Device path: %s\n", path->getCStringNoCopy());
            devicePaths->setObject(path);
            path->release();
            setProperty("ACPI Devices Paths", devicePaths);
            devicePaths->release();
        }
        else
        {
            OSString* path = getACPIPath(backLightDevice);
            IOLog("ACPIBacklight: ACPI Methods _DOS _BCL _BCM _BQC found. Device path: %s\n", path->getCStringNoCopy());
            setProperty("ACPI Device Path", path);
            path->release();
        }
#endif
    }
    return true;
}
开发者ID:chemschool,项目名称:OS-X-ACPI-Backlight,代码行数:65,代码来源:ACPIBacklight.cpp

示例13: resetAndAddDrivers

bool IOCatalogue::resetAndAddDrivers(OSArray * drivers, bool doNubMatching)
{
    bool                   result              = false;
    OSArray              * newPersonalities    = NULL;  // do not release
    OSCollectionIterator * newPIterator        = NULL;  // must release
    OSOrderedSet         * matchSet            = NULL;  // must release
    OSArray              * oldPersonalities    = NULL;  // must release
    OSArray              * kernelPersonalities = NULL;  // must release
    OSString             * errorString         = NULL;  // must release
    OSObject             * object              = NULL;  // do not release
    OSDictionary         * thisNewPersonality  = NULL;  // do not release
    signed int             count, i;

    extern const char    * gIOKernelConfigTables;

    if (drivers) {
        newPersonalities = OSDynamicCast(OSArray, drivers);
        if (!newPersonalities) {
            goto finish;
        }

        newPIterator = OSCollectionIterator::withCollection(newPersonalities);
        if (!newPIterator) {
            goto finish;
        }
        
        matchSet = OSOrderedSet::withCapacity(10, IOServiceOrdering,
            (void *)gIOProbeScoreKey);
        if (!matchSet) {
            goto finish;
        }
    }

   /* Read personalities for the built-in kernel driver classes.
    * We don't have many any more.
    */
    kernelPersonalities = OSDynamicCast(OSArray,
        OSUnserialize(gIOKernelConfigTables, &errorString));
    if (!kernelPersonalities && errorString) {
        IOLog("KernelConfigTables syntax error: %s\n",
            errorString->getCStringNoCopy());
        goto finish;
    }
    
   /* Now copy the current array of personalities so we can reuse them
    * if the new list contains any duplicates. This saves on memory
    * consumption.
    */
    oldPersonalities = OSDynamicCast(OSArray, array->copyCollection());
    if (!oldPersonalities) {
        goto finish;
    }

    result = true;

    IOLog("Resetting IOCatalogue.\n");
    
   /* No goto finish from here to unlock.
    */
    IOLockLock(lock);
    
    array->flushCollection();

   /* Add back the kernel personalities and remove them from the old
    * array so we don't try to match on them again. Go forward through
    * the arrays as this causes the least iteration since kernel personalities
    * should always be first.
    */
    count = kernelPersonalities->getCount();
    for (i = 0; i < count; i++) {
    
       /* Static cast here, as the data is coming from within the kernel image.
        */
        OSDictionary * thisNewPersonality = (OSDictionary *)
            kernelPersonalities->getObject(i);
        array->setObject(thisNewPersonality);

        signed int oldPCount = oldPersonalities->getCount();
        for (signed int oldPIndex = 0; oldPIndex < oldPCount; oldPIndex++) {
            if (thisNewPersonality->isEqualTo(oldPersonalities->getObject(oldPIndex))) {
                oldPersonalities->removeObject(oldPIndex);
                break;
            }
        }
    }

   /* Now add the new set of personalities passed in, using existing
    * copies if we had them in kernel memory already.
    */
    if (newPIterator) {
        OSDictionary * thisOldPersonality = NULL;  // do not release
        
        while ( (object = newPIterator->getNextObject()) ) {

            thisNewPersonality = OSDynamicCast(OSDictionary, object);
            if (!thisNewPersonality) {
                IOLog("IOCatalogue::resetAndAddDrivers() encountered non-dictionary; bailing.\n");
            result = false;
            break;
            }
//.........这里部分代码省略.........
开发者ID:Prajna,项目名称:xnu,代码行数:101,代码来源:IOCatalogue.cpp

示例14: getWorkLoop

// Class start
bool
VoodooPState::start(IOService * provider)
{
	if (!IOService::start(provider)) return false;

	// Printout banner
	InfoLog("%s %s (%s) %s %s [%s]",
			KextProductName,
			KextVersion,
			KextConfig,
			KextBuildDate,
			KextBuildTime,
			KextOSX);
	InfoLog("based on VoodooPower 1.2.3.");
	
	
	
	// Setup workloop and timer
	IOWorkLoop* WorkLoop = getWorkLoop();
	if (!WorkLoop) return false;
	TimerEventSource = 
	IOTimerEventSource::timerEventSource(this, OSMemberFunctionCast(IOTimerEventSource::Action,
																	this,
																	&VoodooPState::LoopTimerEvent));
	if (!TimerEventSource) return false;
	
	if (kIOReturnSuccess != WorkLoop->addEventSource(TimerEventSource)) {
		return false;
	}
	
	// Get a SimpleLock
	SimpleLock = IOSimpleLockAlloc();
	if (!SimpleLock) return false;
	
	// Publish the static characteristics
	OSDictionary * dictionary = OSDictionary::withCapacity(13);
	if (!dictionary) return false;
	OSArray * array = OSArray::withCapacity(PStateCount);
	if (!array) return false;
	setDictionaryNumber(keyCpuCoreTech, CpuCoreTech, dictionary);
	setDictionaryNumber(keyFrontSideBus, CpuFSB, dictionary);
	for (int i = 0; i < PStateCount; i++) {
		OSDictionary * pdictionary = OSDictionary::withCapacity(3);
		if (!pdictionary) return false;
		setDictionaryNumber(keyCurrentFrequency, PState[i].frequency, pdictionary);
		setDictionaryNumber(keyCurrentVoltage, PState[i].voltage, pdictionary);
		setDictionaryNumber(keyFid, PState[i].fid, pdictionary);
		setDictionaryNumber(keyDid, PState[i].did, pdictionary);
		setDictionaryNumber(keyVid, PState[i].vid, pdictionary);
		array->setObject(i, pdictionary);
		pdictionary->release();
	}
	setDictionaryArray(keyPStates, array, dictionary);
	setDictionaryString(keyProductName, KextProductName, dictionary);
	setDictionaryString(keyProductVersion, KextVersion, dictionary);
	setDictionaryString(keyBuildConfig, KextConfig, dictionary);
	setDictionaryString(keyBuildDate, KextBuildDate, dictionary);
	setDictionaryString(keyBuildTime, KextBuildTime, dictionary);
	setDictionaryNumber(keyTimerInterval, TimerInterval, dictionary);
	setProperty(keyCharacteristics, dictionary);

	array->release();
	dictionary->release();

	// set initial pstate
	Request = ColdStart ? (PStateCount-1) : 0;	// hot/cold start

	gPEClockFrequencyInfo.cpu_frequency_max_hz = VoodooFrequencyProc(this,&PState[0]) * Mega;
	gPEClockFrequencyInfo.cpu_frequency_min_hz = VoodooFrequencyProc(this,&PState[PStateCount-1]) * Mega;

	LoopTimerEvent();
	
	// Finalize and kick off the loop
	this->registerService(0);
	Ready = true;

	return true;
}
开发者ID:andyvand,项目名称:Intel-OS-X-LAN-Driver,代码行数:79,代码来源:VoodooPState.cpp

示例15: UniqueProperties

/*********************************************************************
* Remove drivers from the catalog which match the
* properties in the matching dictionary.
*********************************************************************/
bool
IOCatalogue::removeDrivers(
    OSDictionary * matching,
    bool doNubMatching)
{
    OSCollectionIterator * tables;
    OSDictionary         * dict;
    OSOrderedSet         * set;
    OSArray              * arrayCopy;

    if ( !matching )
        return false;

    set = OSOrderedSet::withCapacity(10,
                                     IOServiceOrdering,
                                     (void *)gIOProbeScoreKey);
    if ( !set )
        return false;

    arrayCopy = OSArray::withCapacity(100);
    if ( !arrayCopy ) {
        set->release();
        return false;
    }

    tables = OSCollectionIterator::withCollection(arrayCopy);
    arrayCopy->release();
    if ( !tables ) {
        set->release();
        return false;
    }

    UniqueProperties( matching );

    IOLockLock(lock);
    kernelTables->reset();
    arrayCopy->merge(array);
    array->flushCollection();
    tables->reset();
    while ( (dict = (OSDictionary *)tables->getNextObject()) ) {

        /* This comparison must be done with only the keys in the
         * "matching" dict to enable general searches.
         */
        if ( dict->isEqualTo(matching, matching) ) {
            AddNewImports( set, dict );
            continue;
        }

        array->setObject(dict);
    }
    // Start device matching.
    if ( doNubMatching && (set->getCount() > 0) ) {
        IOService::catalogNewDrivers(set);
        generation++;
    }
    IOLockUnlock(lock);

    set->release();
    tables->release();

    return true;
}
开发者ID:,项目名称:,代码行数:67,代码来源:


注:本文中的OSArray::release方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。