本文整理汇总了C++中OSArray::removeObject方法的典型用法代码示例。如果您正苦于以下问题:C++ OSArray::removeObject方法的具体用法?C++ OSArray::removeObject怎么用?C++ OSArray::removeObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSArray
的用法示例。
在下文中一共展示了OSArray::removeObject方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IORWLockWrite
/*********************************************************************
* Remove drivers from the catalog which match the
* properties in the matching dictionary.
*********************************************************************/
bool
IOCatalogue::removeDrivers(
OSDictionary * matching,
bool doNubMatching)
{
OSOrderedSet * set;
OSCollectionIterator * iter;
OSDictionary * dict;
OSArray * array;
const OSSymbol * key;
unsigned int idx;
if ( !matching )
return false;
set = OSOrderedSet::withCapacity(10,
IOServiceOrdering,
(void *)gIOProbeScoreKey);
if ( !set )
return false;
iter = OSCollectionIterator::withCollection(personalities);
if (!iter)
{
set->release();
return (false);
}
IORWLockWrite(lock);
while ((key = (const OSSymbol *) iter->getNextObject()))
{
array = (OSArray *) personalities->getObject(key);
if (array) for (idx = 0; (dict = (OSDictionary *) array->getObject(idx)); idx++)
{
/* This comparison must be done with only the keys in the
* "matching" dict to enable general searches.
*/
if ( dict->isEqualTo(matching, matching) ) {
set->setObject(dict);
array->removeObject(idx);
idx--;
}
}
// Start device matching.
if ( doNubMatching && (set->getCount() > 0) ) {
IOService::catalogNewDrivers(set);
generation++;
}
}
IORWLockUnlock(lock);
set->release();
iter->release();
return true;
}
示例2: removeAvailableSelection
IOReturn IOAudioSelectorControl::removeAvailableSelection(SInt32 selectionValue)
{
OSCollectionIterator *iterator;
OSArray *newSelections;
OSArray *oldAvailableSelections;
IOReturn result = kIOReturnNotFound;
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)) {
// Remove the selected dictionary from the array
newSelections->removeObject(index);
result = kIOReturnSuccess;
break;
}
index++;
}
availableSelections = newSelections;
setProperty(kIOAudioSelectorControlAvailableSelectionsKey, availableSelections);
oldAvailableSelections->release();
iterator->release();
}
if (kIOReturnSuccess == result) {
sendChangeNotification(kIOAudioControlRangeChangeNotification);
}
return result;
}
示例3: _removeDrivers
IOReturn IOCatalogue::_removeDrivers(OSDictionary * matching)
{
IOReturn ret = kIOReturnSuccess;
OSCollectionIterator * iter;
OSDictionary * dict;
OSArray * array;
const OSSymbol * key;
unsigned int idx;
// remove configs from catalog.
iter = OSCollectionIterator::withCollection(personalities);
if (!iter) return (kIOReturnNoMemory);
while ((key = (const OSSymbol *) iter->getNextObject()))
{
array = (OSArray *) personalities->getObject(key);
if (array) for (idx = 0; (dict = (OSDictionary *) array->getObject(idx)); idx++)
{
/* 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))
{
array->removeObject(idx);
idx--;
}
}
}
iter->release();
return ret;
}
示例4: assert
IORegistryEntry *
IODeviceTreeAlloc( void * dtTop )
{
IORegistryEntry * parent;
IORegistryEntry * child;
IORegistryIterator * regIter;
DTEntryIterator iter;
DTEntry dtChild;
DTEntry mapEntry;
OSArray * stack;
OSData * prop;
OSDictionary * allInts;
vm_offset_t * dtMap;
unsigned int propSize;
bool intMap;
bool freeDT;
gIODTPlane = IORegistryEntry::makePlane( kIODeviceTreePlane );
gIODTNameKey = OSSymbol::withCStringNoCopy( "name" );
gIODTUnitKey = OSSymbol::withCStringNoCopy( "AAPL,unit-string" );
gIODTCompatibleKey = OSSymbol::withCStringNoCopy( "compatible" );
gIODTTypeKey = OSSymbol::withCStringNoCopy( "device_type" );
gIODTModelKey = OSSymbol::withCStringNoCopy( "model" );
gIODTSizeCellKey = OSSymbol::withCStringNoCopy( "#size-cells" );
gIODTAddressCellKey = OSSymbol::withCStringNoCopy( "#address-cells" );
gIODTRangeKey = OSSymbol::withCStringNoCopy( "ranges" );
gIODTPersistKey = OSSymbol::withCStringNoCopy( "IODTPersist" );
assert( gIODTPlane && gIODTCompatibleKey
&& gIODTTypeKey && gIODTModelKey
&& gIODTSizeCellKey && gIODTAddressCellKey && gIODTRangeKey
&& gIODTPersistKey );
gIODTDefaultInterruptController
= OSSymbol::withCStringNoCopy("IOPrimaryInterruptController");
gIODTNWInterruptMappingKey
= OSSymbol::withCStringNoCopy("IONWInterrupts");
gIODTAAPLInterruptsKey
= OSSymbol::withCStringNoCopy("AAPL,interrupts");
gIODTPHandleKey
= OSSymbol::withCStringNoCopy("AAPL,phandle");
gIODTInterruptParentKey
= OSSymbol::withCStringNoCopy("interrupt-parent");
gIODTPHandles = OSArray::withCapacity( 1 );
gIODTPHandleMap = OSArray::withCapacity( 1 );
gIODTInterruptCellKey
= OSSymbol::withCStringNoCopy("#interrupt-cells");
assert( gIODTDefaultInterruptController && gIODTNWInterruptMappingKey
&& gIODTAAPLInterruptsKey
&& gIODTPHandleKey && gIODTInterruptParentKey
&& gIODTPHandles && gIODTPHandleMap
&& gIODTInterruptCellKey
);
freeDT = (kSuccess == DTLookupEntry( 0, "/chosen/memory-map", &mapEntry ))
&& (kSuccess == DTGetProperty( mapEntry,
"DeviceTree", (void **) &dtMap, &propSize ))
&& ((2 * sizeof(uint32_t)) == propSize);
parent = MakeReferenceTable( (DTEntry)dtTop, freeDT );
stack = OSArray::withObjects( (const OSObject **) &parent, 1, 10 );
DTCreateEntryIterator( (DTEntry)dtTop, &iter );
do {
parent = (IORegistryEntry *)stack->getObject( stack->getCount() - 1);
//parent->release();
stack->removeObject( stack->getCount() - 1);
while( kSuccess == DTIterateEntries( iter, &dtChild) ) {
child = MakeReferenceTable( dtChild, freeDT );
child->attachToParent( parent, gIODTPlane);
AddPHandle( child );
if( kSuccess == DTEnterEntry( iter, dtChild)) {
stack->setObject( parent);
parent = child;
}
// only registry holds retain
child->release();
}
} while( stack->getCount()
&& (kSuccess == DTExitEntry( iter, &dtChild)));
stack->release();
DTDisposeEntryIterator( iter);
// parent is now root of the created tree
// make root name first compatible entry (purely cosmetic)
if( (prop = (OSData *) parent->getProperty( gIODTCompatibleKey))) {
//.........这里部分代码省略.........
示例5: OSKextLog
//.........这里部分代码省略.........
OSBoolean *devOnlyBool = OSDynamicCast(OSBoolean,
infoDict->getObject(kOSBundleDeveloperOnlyKey));
if (devOnlyBool == kOSBooleanTrue) {
dontLoad = true;
}
}
/* Skip and free kexts that are only needed when booted from a ram disk.
*/
if (ramDiskBoot == false) {
OSBoolean *ramDiskOnlyBool = OSDynamicCast(OSBoolean,
infoDict->getObject(kOSBundleRamDiskOnlyKey));
if (ramDiskOnlyBool == kOSBooleanTrue) {
dontLoad = true;
}
}
if (dontLoad == true) {
OSString *bundleID = OSDynamicCast(OSString,
infoDict->getObject(kCFBundleIdentifierKey));
if (bundleID) {
OSKextLog(NULL, kOSKextLogWarningLevel | kOSKextLogGeneralFlag,
"Kext %s not loading.", bundleID->getCStringNoCopy());
}
OSNumber *addressNum = OSDynamicCast(OSNumber,
infoDict->getObject(kPrelinkExecutableLoadKey));
OSNumber *lengthNum = OSDynamicCast(OSNumber,
infoDict->getObject(kPrelinkExecutableSizeKey));
if (addressNum && lengthNum) {
#error Pick the right way to free prelinked data on this arch
}
infoDictArray->removeObject(i--);
continue;
}
#endif /* NO_KEXTD */
/* Create the kext for the entry, then release it, because the
* kext system keeps them around until explicitly removed.
* Any creation/registration failures are already logged for us.
*/
OSKext * newKext = OSKext::withPrelinkedInfoDict(infoDict, (kaslrOffsets ? TRUE : FALSE));
OSSafeReleaseNULL(newKext);
}
/* slide kxld relocations */
if (kaslrOffsets && vm_kernel_slide > 0) {
int slidKextAddrCount = 0;
int badSlideAddr = 0;
int badSlideTarget = 0;
kaslrPackedOffsets * myOffsets = NULL;
myOffsets = (kaslrPackedOffsets *) kaslrOffsets->getBytesNoCopy();
for (uint32_t j = 0; j < myOffsets->count; j++) {
uint64_t slideOffset = (uint64_t) myOffsets->offsetsArray[j];
uintptr_t * slideAddr = (uintptr_t *) ((uint64_t)prelinkData + slideOffset);
int slideAddrSegIndex = -1;
int addrToSlideSegIndex = -1;
slideAddrSegIndex = __whereIsAddr( (vm_offset_t)slideAddr, &plk_segSizes[0], &plk_segAddrs[0], PLK_SEGMENTS );
if (slideAddrSegIndex >= 0) {
addrToSlideSegIndex = __whereIsAddr( (vm_offset_t)(*slideAddr + vm_kernel_slide), &plk_segSizes[0], &plk_segAddrs[0], PLK_SEGMENTS );
if (addrToSlideSegIndex < 0) {
示例6: resetAndAddDrivers
bool IOCatalogue::resetAndAddDrivers(OSArray * drivers, bool doNubMatching)
{
bool result = false;
OSArray * newPersonalities = NULL; // do not release
OSCollectionIterator * iter = NULL; // must release
OSOrderedSet * matchSet = NULL; // must release
const OSSymbol * key;
OSArray * array;
OSDictionary * thisNewPersonality = NULL; // do not release
OSDictionary * thisOldPersonality = NULL; // do not release
signed int idx, newIdx;
if (drivers) {
newPersonalities = OSDynamicCast(OSArray, drivers);
if (!newPersonalities) {
goto finish;
}
matchSet = OSOrderedSet::withCapacity(10, IOServiceOrdering,
(void *)gIOProbeScoreKey);
if (!matchSet) {
goto finish;
}
iter = OSCollectionIterator::withCollection(personalities);
if (!iter) {
goto finish;
}
}
result = true;
IOLog("Resetting IOCatalogue.\n");
/* No goto finish from here to unlock.
*/
IORWLockWrite(lock);
while ((key = (const OSSymbol *) iter->getNextObject()))
{
array = (OSArray *) personalities->getObject(key);
if (!array) continue;
for (idx = 0; (thisOldPersonality = (OSDictionary *) array->getObject(idx)); idx++)
{
if (thisOldPersonality->getObject("KernelConfigTable")) continue;
if (newPersonalities) for (newIdx = 0;
(thisNewPersonality = (OSDictionary *) newPersonalities->getObject(newIdx));
newIdx++)
{
/* Unlike in other functions, this comparison must be exact!
* The catalogue must be able to contain personalities that
* are proper supersets of others.
* Do not compare just the properties present in one driver
* pesonality or the other.
*/
if (thisNewPersonality->isEqualTo(thisOldPersonality))
break;
}
if (thisNewPersonality)
{
// dup, ignore
newPersonalities->removeObject(newIdx);
}
else
{
// not in new set - remove
// only remove dictionary if this module in not loaded - 9953845
if ( isModuleLoaded(thisOldPersonality) == false )
{
if (matchSet) matchSet->setObject(thisOldPersonality);
array->removeObject(idx);
idx--;
}
}
}
}
// add new
for (newIdx = 0;
(thisNewPersonality = (OSDictionary *) newPersonalities->getObject(newIdx));
newIdx++)
{
OSKext::uniquePersonalityProperties(thisNewPersonality);
addPersonality(thisNewPersonality);
matchSet->setObject(thisNewPersonality);
}
/* Finally, start device matching on all new & removed personalities.
*/
if (result && doNubMatching && (matchSet->getCount() > 0)) {
IOService::catalogNewDrivers(matchSet);
generation++;
}
IORWLockUnlock(lock);
finish:
if (matchSet) matchSet->release();
if (iter) iter->release();
return result;
//.........这里部分代码省略.........
示例7: 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;
}
//.........这里部分代码省略.........