本文整理汇总了C++中OSObject::release方法的典型用法代码示例。如果您正苦于以下问题:C++ OSObject::release方法的具体用法?C++ OSObject::release怎么用?C++ OSObject::release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSObject
的用法示例。
在下文中一共展示了OSObject::release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: iokit_post_constructor_init
void iokit_post_constructor_init(void)
{
IORegistryEntry * root;
OSObject * obj;
root = IORegistryEntry::initialize();
assert( root );
IOService::initialize();
IOCatalogue::initialize();
IOStatistics::initialize();
OSKext::initialize();
IOUserClient::initialize();
IOMemoryDescriptor::initialize();
IORootParent::initialize();
// Initializes IOPMinformeeList class-wide shared lock
IOPMinformeeList::getSharedRecursiveLock();
obj = OSString::withCString( version );
assert( obj );
if( obj ) {
root->setProperty( kIOKitBuildVersionKey, obj );
obj->release();
}
obj = IOKitDiagnostics::diagnostics();
if( obj ) {
root->setProperty( kIOKitDiagnosticsKey, obj );
obj->release();
}
}
示例2: PrintTraces
/******************************************************************************
* ACPIDebug::PrintTraces
******************************************************************************/
void ACPIDebug::PrintTraces()
{
for (;;)
{
// see if there are any trace items in the RING
UInt32 count = 0;
if (kIOReturnSuccess != m_pDevice->evaluateInteger("COUN", &count))
{
IOLog("ACPIDebug: evaluateObject of COUN method failed\n");
break;
}
if (!count)
break;
// gather the next item from RING and print it
OSObject* debug;
if (kIOReturnSuccess == m_pDevice->evaluateObject("FTCH", &debug) &&
NULL != debug)
{
static char buf[2048];
// got a valid object, format and print it...
FormatDebugString(debug, buf, sizeof(buf)/sizeof(buf[0]));
IOLog("ACPIDebug: %s\n", buf);
debug->release();
}
}
}
示例3: copyClientEntitlement
bool IOHIDEventSystemUserClient::
initWithTask(task_t owningTask, void * /* security_id */, UInt32 /* type */)
{
bool result = false;
OSObject* entitlement = copyClientEntitlement(owningTask, kIOHIDSystemUserAccessServiceEntitlement);
if (entitlement) {
result = (entitlement == kOSBooleanTrue);
entitlement->release();
}
if (!result) {
proc_t process;
process = (proc_t)get_bsdtask_info(owningTask);
char name[255];
bzero(name, sizeof(name));
proc_name(proc_pid(process), name, sizeof(name));
HIDLogError("%s is not entitled", name);
goto exit;
}
result = super::init();
require_action(result, exit, HIDLogError("failed"));
exit:
return result;
}
示例4: copyProperty
bool
IOUSBNub::USBCompareProperty( OSDictionary * matching, const OSSymbol * key )
{
// We return success iff we match the key in the dictionary with the key in
// the property table.
//
OSObject *value;
bool matches = false;
OSObject *myProperty = NULL;
value = matching->getObject( key );
if ( value)
{
myProperty = copyProperty(key);
if (myProperty)
{
matches = value->isEqualTo( myProperty);
myProperty->release();
}
}
else
matches = false;
return matches;
}
示例5: CompareProperty
//---------------------------------------------------------------------------
// Compare the properties in the supplied table to this object's properties.
bool CompareProperty( IOService * owner, OSDictionary * matching, const char * key, 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 * value;
OSObject * property;
bool matches = true;
value = matching->getObject( key );
if( value)
{
property = owner->copyProperty( key );
if ( property )
{
matches = value->isEqualTo( property );
if (matches && score)
*score += increment;
property->release();
}
else
matches = false;
}
return matches;
}
示例6: newUserClient
IOReturn
IOI2CDevice::newUserClient(
task_t owningTask,
void *securityID,
UInt32 type,
OSDictionary *properties,
IOUserClient **handler)
{
IOUserClient *client;
OSObject *temp;
DLOG("%s::newUserClient\n", getName());
if (type != kIOI2CUserClientType)
return super::newUserClient(owningTask,securityID,type,properties,handler);
if (IOUserClient::clientHasPrivilege(securityID, "root") != kIOReturnSuccess)
{
ERRLOG("%s::newUserClient: Can't create user client, not privileged\n", getName());
return kIOReturnNotPrivileged;
}
temp = OSMetaClass::allocClassWithName("IOI2CUserClient");
if (!temp)
return kIOReturnNoMemory;
if (OSDynamicCast(IOUserClient, temp))
client = (IOUserClient *) temp;
else
{
temp->release();
return kIOReturnUnsupported;
}
if ( !client->initWithTask(owningTask, securityID, type, properties) )
{
client->release();
return kIOReturnBadArgument;
}
if ( !client->attach(this) )
{
client->release();
return kIOReturnUnsupported;
}
if ( !client->start(this) )
{
client->detach(this);
client->release();
return kIOReturnUnsupported;
}
*handler = client;
return kIOReturnSuccess;
}
示例7: sizeof
IOMapper * IOMapper::copyMapperForDeviceWithIndex(IOService * device, unsigned int index)
{
OSData *data;
OSObject * obj;
IOMapper * mapper = NULL;
OSDictionary * matching;
obj = device->copyProperty("iommu-parent");
if (!obj) return (NULL);
if ((mapper = OSDynamicCast(IOMapper, obj))) goto found;
if ((data = OSDynamicCast(OSData, obj)))
{
if (index >= data->getLength() / sizeof(UInt32)) goto done;
data = OSData::withBytesNoCopy((UInt32 *)data->getBytesNoCopy() + index, sizeof(UInt32));
if (!data) goto done;
matching = IOService::propertyMatching(gIOMapperIDKey, data);
data->release();
}
else
matching = IOService::propertyMatching(gIOMapperIDKey, obj);
if (matching)
{
mapper = OSDynamicCast(IOMapper, IOService::waitForMatchingService(matching));
matching->release();
}
done:
if (obj) obj->release();
found:
if (mapper)
{
if (!mapper->fAllocName)
{
char name[MACH_ZONE_NAME_MAX_LEN];
char kmodname[KMOD_MAX_NAME];
vm_tag_t tag;
uint32_t kmodid;
tag = IOMemoryTag(kernel_map);
if (!(kmodid = vm_tag_get_kext(tag, &kmodname[0], KMOD_MAX_NAME)))
{
snprintf(kmodname, sizeof(kmodname), "%d", tag);
}
snprintf(name, sizeof(name), "%s.DMA.%s", kmodname, device->getName());
mapper->fAllocName = kern_allocation_name_allocate(name, 16);
}
}
return (mapper);
}
示例8: setInterface
void USBInterfaceShim::setInterface(IOService* interface)
{
OSObject* prev = m_pInterface;
m_pInterface = OSDynamicCast(IOUSBInterface, interface);
if (m_pInterface)
m_pInterface->retain();
if (prev)
prev->release();
}
示例9: setDevice
void USBDeviceShim::setDevice(IOService* provider)
{
OSObject* prev = m_pDevice;
m_pDevice = OSDynamicCast(IOUSBDevice, provider);
if (m_pDevice)
m_pDevice->retain();
if (prev)
prev->release();
}
示例10: OSDynamicCast
OSDictionary*
IOFireWireUserClientIniter::dictionaryDeepCopy(
OSDictionary* srcDictionary)
{
//IOLog( "IOFireWireUserClientIniter<0x%08lx>::dictionaryDeepCopy - srcDictionary = 0x%08lx\n", this, srcDictionary );
OSDictionary* result = NULL;
OSObject* srcObject = NULL;
OSCollectionIterator* srcIterator = NULL;
OSSymbol* keyObject = NULL;
result = OSDictionary::withCapacity(srcDictionary->getCount());
if (result)
{
srcIterator = OSCollectionIterator::withCollection(srcDictionary);
if (srcIterator)
{
while ( (keyObject = OSDynamicCast(OSSymbol, srcIterator->getNextObject())) )
{
srcObject = srcDictionary->getObject(keyObject);
if (OSDynamicCast(OSDictionary, srcObject))
{
srcObject = dictionaryDeepCopy((OSDictionary*)srcObject);
result->setObject(keyObject, srcObject);
// copyDictionaryProperty creates a new dictionary, so we should release
// it after we add it to our dictionary
srcObject->release();
}
else
{
result->setObject(keyObject, srcObject);
}
}
srcIterator->release();
}
}
//IOLog( "IOFireWireUserClientIniter<0x%08lx>::dictionaryDeepCopy - return\n", this );
return result;
}
示例11: initMACfromACPI
bool NullEthernet::initMACfromACPI()
{
bool result = false;
OSObject *ret = NULL;
IOACPIPlatformDevice* pACPI = OSDynamicCast(IOACPIPlatformDevice, m_pProvider);
if (NULL != pACPI && kIOReturnSuccess == pACPI->evaluateObject("MAC", &ret) && NULL != ret)
{
// get MAC address from DSDT if provided...
OSData* pData = OSDynamicCast(OSData, ret);
if (pData && pData->getLength() == kIOEthernetAddressSize)
{
bcopy(pData->getBytesNoCopy(), m_rgMacAddr, kIOEthernetAddressSize);
AlwaysLog("Using MAC address from DSDT: %02x:%02x:%02x:%02x:%02x:%02x\n", m_rgMacAddr[0], m_rgMacAddr[1], m_rgMacAddr[2], m_rgMacAddr[3], m_rgMacAddr[4], m_rgMacAddr[5]);
result = true;
}
ret->release();
}
return result;
}
示例12: receivedUpdate
// Received an update of a specific value
void WirelessHIDDevice::receivedUpdate(unsigned char type, unsigned char *data)
{
switch (type)
{
case 0x13: // Battery level
battery = data[0];
{
OSObject *prop = OSNumber::withNumber(battery, 8);
if (prop != NULL)
{
setProperty(kIOWirelessBatteryLevel, prop);
prop->release();
}
}
break;
default:
break;
}
}
示例13: OSDynamicCast
static bool
getPCSPortMapping(
IORegistryEntry * root,
UInt32 portNum,
UInt8 * enableOffset,
UInt8 * enableMask,
UInt8 * presenceOffset,
UInt8 * presenceMask )
{
OSObject * prop;
OSData * data;
const PCSPortMap * portMap = gDefaultPortMap;
if (!root || (portNum > kSerialATAPort3) ||
root->getProperty( kSerialATAKey ) != kOSBooleanTrue)
return false;
prop = root->copyProperty( kPCSPortMapKey );
data = OSDynamicCast(OSData, prop);
if (data && (data->getLength() == sizeof(gDefaultPortMap)))
{
portMap = (const PCSPortMap *) data->getBytesNoCopy();
}
if (enableOffset)
*enableOffset = portMap[portNum].enableOffset;
if (enableMask)
*enableMask = portMap[portNum].enableMask;
if (presenceOffset)
*presenceOffset = portMap[portNum].presenceOffset;
if (presenceMask)
*presenceMask = portMap[portNum].presenceMask;
if (prop) prop->release();
return true;
}
示例14: createNubs
static void createNubs(IOService *provider) {
const char nameID[2][8] = {"@0,name", "@1,name"};
const char name[11] = "Aty,Radeon";
const char typeID[2][15] = {"@0,device_type", "@1,device_type"};
const char type[] = "display";
OSObject *tempObj;
int i;
if (provider->getProperty(kIONDRVIgnoreKey)) return;
provider->setProperty(kIONDRVIgnoreKey, kOSBooleanTrue); //prevent IONDRVFramebuffer from match
LOG("createNubs\n");
if (!provider->getProperty("@0,name") && !provider->getProperty("@1,name")) {
for (i = 0;i < 2;i++) { // Debug
tempObj = OSData::withBytes(name, 11);
provider->setProperty(nameID[i], tempObj);
tempObj->release();
tempObj = OSData::withBytes(type, 8);
provider->setProperty(typeID[i], tempObj);
tempObj->release();
}
}
// have to move below part from IONDRVFramebuffer to make it work
IORegistryIterator * iter;
IORegistryEntry * next;
IOService * newNub;
OSArray * toDo = 0;
bool firstLevel;
OSData * data;
if (provider->getProperty("@0,name"))
{
OSDictionary * dict;
OSCollectionIterator * keys;
const OSSymbol * key;
char buffer[80];
const char * keyChrs;
size_t len;
char c;
dict = provider->dictionaryWithProperties();
keys = OSCollectionIterator::withCollection(dict);
if (dict)
dict->release();
if (keys)
{
while ((key = OSDynamicCast(OSSymbol, keys->getNextObject())))
{
keyChrs = key->getCStringNoCopy();
if ('@' != keyChrs[0])
continue;
len = 0;
do
{
c = keyChrs[len];
if (!c || (c == ','))
break;
buffer[len] = c;
len++;
}
while (len < (sizeof(buffer) - 1));
if (!c)
continue;
buffer[len] = 0;
keyChrs += len + 1;
next = provider->childFromPath(buffer, gIODTPlane);
if (!next)
{
next = new IOService;
if (next && !next->init())
{
next->release();
next = 0;
}
if (!next)
continue;
next->setLocation(&buffer[1]);
if (!next->attachToParent(provider, gIODTPlane))
continue;
}
OSObject * obj = dict->getObject(key);
next->setProperty(keyChrs, dict->getObject(key));
if (!strcmp(keyChrs, "name"))
{
OSData * data = OSDynamicCast(OSData, obj);
if (data)
next->setName((const char *) data->getBytesNoCopy());
}
next->release();
provider->removeProperty(key);
}
keys->release();
}
}
//.........这里部分代码省略.........
示例15: testDictionary
void testDictionary()
{
bool res = true;
void *spaceCheck, *spaceCheck2, *spaceCheck3;
OSObject *cache[numStrCache];
OSString *str;
const OSSymbol *symCache[numStrCache], *sym;
OSDictionary *dict1, *dict2;
int i, numSymbols, count1, count2;
// Do first test without memory leak tests to initialise the metaclass
dict1 = OSDictionary::withCapacity(1);
TEST_ASSERT('D', "0a", dict1);
if (dict1)
dict1->release();
// Grow the symbol pool to maximum
for (i = 0; i < numStrCache; i++)
symCache[i] = OSSymbol::withCStringNoCopy(strCache[i]);
for (i = 0; i < numStrCache; i++)
symCache[i]->release();
// Create and destroy a dictionary
spaceCheck = checkPointSpace();
dict1 = OSDictionary::withCapacity(1);
TEST_ASSERT('D', "1a", dict1);
if (dict1) {
TEST_ASSERT('D', "1b", !dict1->getCount());
TEST_ASSERT('D', "1c", 1 == dict1->getCapacity());
TEST_ASSERT('D', "1d", 1 == dict1->getCapacityIncrement());
TEST_ASSERT('D', "1e", 4 == dict1->setCapacityIncrement(4));
TEST_ASSERT('D', "1f", 4 == dict1->getCapacityIncrement());
TEST_ASSERT('D', "1g", 8 == dict1->ensureCapacity(5));
spaceCheck2 = checkPointSpace();
sym = OSSymbol::withCStringNoCopy(strCache[0]);
spaceCheck3 = checkPointSpace();
TEST_ASSERT('D', "1h", dict1->setObject((OSObject *) sym, sym));
TEST_ASSERT('D', "1i", (OSObject *) sym == dict1->getObject(sym));
sym->release();
TEST_ASSERT('D', "1i", 2 == sym->getRetainCount());
res = res && checkSpace("(D)1j", spaceCheck3, 0);
TEST_ASSERT('D', "1k", 1 == dict1->getCount());
dict1->flushCollection();
TEST_ASSERT('D', "1l", !dict1->getCount());
res = res && checkSpace("(D)1m", spaceCheck2, 0);
dict1->release();
}
res = res && checkSpace("(D)1", spaceCheck, 0);
// Check the creation of a sizable OSDictionary from an array of IOObjects
// Also check indexing into the array.
spaceCheck = checkPointSpace();
for (i = 0, numSymbols = 0; i < numStrCache; i++) {
sym = OSSymbol::withCStringNoCopy(strCache[i]);
if (1 == sym->getRetainCount())
symCache[numSymbols++] = sym;
else
sym->release();
}
dict1 = OSDictionary::withObjects(
(OSObject **) symCache, symCache, numSymbols, numSymbols);
TEST_ASSERT('D', "2a", dict1);
count1 = count2 = 0;
for (i = 0; i < numSymbols; i++)
count1 += (symCache[i]->getRetainCount() == 3);
TEST_ASSERT('D', "2b", count1 == numSymbols);
if (dict1) {
TEST_ASSERT('D', "2c", numSymbols == (int) dict1->getCount());
TEST_ASSERT('D', "2d", numSymbols == (int) dict1->getCapacity());
TEST_ASSERT('D', "2e",
numSymbols == (int) dict1->getCapacityIncrement());
for (i = dict1->getCount(); --i >= 0; ) {
str = (OSString *) dict1->getObject(symCache[i]);
if (str != (OSString *) symCache[i]) {
verPrintf(("testDictionary(D) test 2f%d failed\n", i));
res = false;
}
}
dict1->release();
}
count1 = count2 = 0;
for (i = 0; i < numSymbols; i++) {
count1 += (symCache[i]->getRetainCount() == 1);
symCache[i]->release();
}
TEST_ASSERT('D', "2g", count1 == numSymbols);
res = res && checkSpace("(D)2", spaceCheck, 0);
// Check the creation of a sizable Dictionary from an array of IOStrings
// Also check searching dictionary use OSString for a key.
spaceCheck = checkPointSpace();
for (i = 0, numSymbols = 0; i < numStrCache; i++) {
sym = OSSymbol::withCStringNoCopy(strCache[i]);
if (1 == sym->getRetainCount()) {
cache[numSymbols] = OSString::withCStringNoCopy(strCache[i]);
//.........这里部分代码省略.........