Exemplo n.º 1
0
/* =============================================================================
    Name:	IUnknownRelease()
	Description:
        This function takes a tick from a plugin instance's reference count.
		When the reference count goes down to zero the object self-destructs.
	Input Parameters:
        obj			-	The 'this' pointer.
	Output Parameters:
        None.    Return Value:
        ULONG		-	Updated value of the reference count, or zero
                        in case of an error.
* ========================================================================== */
static ULONG IUnknownRelease(void* obj)
{
    IUnknownInstance* instance = (IUnknownInstance*) obj;
    ULONG refCount = 0;
    
    // We can't do much with errors here since we can only return
    // updated reference count value.
    if (instance != NULL)
    {
	// Get updated refCount value (should be under mutex):
	// Make sure refCount is non-zero:
	if (0 == instance->refCount)
	{
	    instance = NULL;
	    return(refCount);
	}

	refCount = --instance->refCount;
	
	// Is it time to self-destruct?
	if (0 == refCount)
	{	    
	    // Unregister 'instance for factory' with CoreFoundation:
	    CFPlugInRemoveInstanceForFactory(instance->factoryID);														
	    // Release used factoryID:				
	    CFRelease(instance->factoryID);
	    instance->factoryID = NULL;
	    
	    // Deallocate object's memory block:
	    free((void*) instance);
	    instance = NULL;
	}
    }    
    return refCount;    
}
Exemplo n.º 2
0
static void _deallocCFPlugType(CFPlugType *myInstance)
{
	CFUUIDRef factoryID = myInstance->_factoryID;
	free(myInstance);
	if (factoryID) {
		CFPlugInRemoveInstanceForFactory(factoryID);
		CFRelease(factoryID);
	}
}
Exemplo n.º 3
0
//	Utility function that deallocates the instance when
//	the refCount goes to zero.
//      In the current implementation importer interfaces are never deallocated
//      but implement this as this might change in the future
void DeallocMetadataImporterPluginType(MetadataImporterPluginType *thisInstance)
{
    CFUUIDRef theFactoryID = thisInstance->factoryID;
    free(thisInstance);
    if (theFactoryID)
	{
        CFPlugInRemoveInstanceForFactory(theFactoryID);
        CFRelease(theFactoryID);
    }
}
Exemplo n.º 4
0
// -----------------------------------------------------------------------------
//	DeallocSampleCMPluginType
// -----------------------------------------------------------------------------
//	Utility function that deallocates the instance when
//	the refCount goes to zero.
//
static void DeallocSampleCMPluginType( SampleCMPluginType* thisInstance )
{
	CFUUIDRef	theFactoryID = thisInstance->factoryID;
	free( thisInstance );
	if ( theFactoryID )
	{
		CFPlugInRemoveInstanceForFactory( theFactoryID );
		CFRelease( theFactoryID );
	}
}
Exemplo n.º 5
0
void IOHIDIUnknown::factoryRelease()
{
    if (1 == factoryRefCount--) {
        CFUUIDRef factoryId = kIOHIDDeviceFactoryID;
    
        CFPlugInRemoveInstanceForFactory(factoryId);
        CFRelease(factoryId);
    }
    else if (factoryRefCount < 0)
        factoryRefCount = 0;
}
Exemplo n.º 6
0
Arquivo: Main.c Projeto: stesla/koan
// -----------------------------------------------------------------------------
//	DeallocKoanLogImporterMDImporterPluginType
// -----------------------------------------------------------------------------
//	Utility function that deallocates the instance when
//	the refCount goes to zero.
//      In the current implementation importer interfaces are never deallocated
//      but implement this as this might change in the future
//
void
DeallocMetadataImporterPluginType (MetadataImporterPluginType *instance)
{
    CFUUIDRef factoryID = instance->factoryID;

    free (instance);
    if (factoryID)
    {
        CFPlugInRemoveInstanceForFactory ((CFUUIDRef) instance);
        CFRelease (instance);
    }
}
Exemplo n.º 7
0
    // Utility function that deallocates the instance when
    // the refCount goes to zero.
    static void _deallocMyType(MyType * obj) {
#if PRINTDEBUG
        printf("JAS: _deallocMyType\n");
#endif

        CFUUIDRef factoryID = obj->_factoryID;
        free(obj);
        if (factoryID) {
            CFPlugInRemoveInstanceForFactory(factoryID);
            CFRelease(factoryID);
        }
    }
Exemplo n.º 8
0
// -----------------------------------------------------------------------------
//    DeallocQuickLookGeneratorPluginType
// -----------------------------------------------------------------------------
//    Utility function that deallocates the instance when
//    the refCount goes to zero.
//      In the current implementation generator interfaces are never deallocated
//      but implement this as this might change in the future
//
void DeallocQuickLookGeneratorPluginType(QuickLookGeneratorPluginType *thisInstance)
{
    CFUUIDRef theFactoryID;

    theFactoryID = thisInstance->factoryID;
    /* Free the conduitInterface table up */
    free(thisInstance->conduitInterface);

    /* Free the instance structure */
    free(thisInstance);
    if (theFactoryID) {
        CFPlugInRemoveInstanceForFactory(theFactoryID);
        CFRelease(theFactoryID);
    }
}
Exemplo n.º 9
0
/*****************************************************************************
 * Dealloc
 * - 
 * Much like Obj-C dealloc this method is responsible for releasing any object
 * this plugin is holding. Unlike ObjC, you call directly free() instead of 
 * [super dalloc].
 *****************************************************************************/
static void Dealloc(BonjourUserEventsPlugin* plugin)
{
	CFUUIDRef factoryID = plugin->_factoryID;
	
	if (factoryID)
	{
		CFPlugInRemoveInstanceForFactory(factoryID);
		CFRelease(factoryID);
	}
	
	if (plugin->_tokenToBrowserMap)
		CFRelease(plugin->_tokenToBrowserMap);
	
	if (plugin->_browsers)
		CFRelease(plugin->_browsers);
	
	if (plugin->_onAddEvents)
		CFRelease(plugin->_onAddEvents);
	
	if (plugin->_onRemoveEvents)
		CFRelease(plugin->_onRemoveEvents);
	
	if (plugin->_whileServiceExist)
		CFRelease(plugin->_whileServiceExist);
	
	if (plugin->_timers)
	{
		CFIndex i;
		CFIndex count = CFArrayGetCount(plugin->_timers);
		CFRunLoopRef crl = CFRunLoopGetCurrent();
		
		for (i = 0; i < count; ++i)
		{
			CFRunLoopTimerRef timer = (CFRunLoopTimerRef)CFArrayGetValueAtIndex(plugin->_timers, i);
			CFRunLoopRemoveTimer(crl, timer, kCFRunLoopCommonModes);
		}
		
		CFRelease(plugin->_timers);
	}
	
	free(plugin);
}
void
SATSMARTClient::sFactoryRelease ( void )
{

    if ( sFactoryRefCount-- == 1 )
    {

        CFUUIDRef factoryID = kIOATASMARTLibFactoryID;

        CFPlugInRemoveInstanceForFactory ( factoryID );
        CFRelease ( factoryID );

    }

    else if ( sFactoryRefCount < 0 )
    {
        sFactoryRefCount = 0;
    }

}
/*****************************************************************************
* Dealloc
* -
* Much like Obj-C dealloc this method is responsible for releasing any object
* this plugin is holding. Unlike ObjC, you call directly free() instead of
* [super dalloc].
*****************************************************************************/
static void Dealloc(BonjourUserEventsPlugin* plugin)
{
    CFUUIDRef factoryID = plugin->_factoryID;

    if (factoryID)
    {
        CFPlugInRemoveInstanceForFactory(factoryID);
        CFRelease(factoryID);
    }

    if (plugin->_tokenToBrowserMap)
        CFRelease(plugin->_tokenToBrowserMap);

    if (plugin->_browsers)
        CFRelease(plugin->_browsers);

    if (plugin->_onAddEvents)
        CFRelease(plugin->_onAddEvents);

    if (plugin->_onRemoveEvents)
        CFRelease(plugin->_onRemoveEvents);

    free(plugin);
}
Exemplo n.º 12
0
HP_HardwarePlugIn::~HP_HardwarePlugIn()
{
	CFPlugInRemoveInstanceForFactory(mFactoryUUID.GetCFObject());
}
//------------------------------------------------------------------------------
// IOHIDEventSystemStatistics::IOHIDEventSystemStatistics
//------------------------------------------------------------------------------
IOHIDEventSystemStatistics::~IOHIDEventSystemStatistics()
{
    CFPlugInRemoveInstanceForFactory( _factoryID );
    CFRelease( _factoryID );
}
Exemplo n.º 14
0
IOFireWireSBP2LibLUN::~IOFireWireSBP2LibLUN()
{
    CFPlugInRemoveInstanceForFactory( fFactoryId );
    CFRelease( fFactoryId );
}