Getting confused. If an event or Interface method is returning or
byreffing an object, do you really need to unlock it, or not? If we
don't, we leak our retInstance object ("myClass", see below). (Unless
the dictionary class containing myClass instances is leaking)
Example:
REALmethodDefinition InterfaceMethods[] = {
/*0*/ { (REALproc)nil, REALnoImplementation, "GetStringIdentifier
(utf8name As String) As myClass"},
};
REALinterfaceDefinition Interface = {
kCurrentREALControlVersion,
// just pass
kCurrentREALControlVersion
"StringIdentifier",
// interface name
InterfaceMethods,
// list of methods the interface requires
sizeof(InterfaceMethods) / sizeof(REALmethodDefinition) // how many
methods there are
};
typedef void* APIIdentifier;
//The lib callback
APIIdentifier API_GetStringIdentifier(const char *name)
{
APIIdentifier api = NULL;
REALstring theName = REALBuildString(name, strlen(name));
if (myInstance)
{
REALobject (*_fp)(REALobject, REALstring);
_fp = (REALobject(*)(REALobject,
REALstring))REALInterfaceRoutine
(myInstance,
Interface.name, "GetStringIdentifier");
REALobject retInstance = nil;
if (_fp)
{
retInstance = _fp(myInstance, theName);
}
REALUnlockString(theName);
api = GetAPIIdentifier(retInstance);
REALUnlockObject(retInstance); <-------------------
necessary???
}
return api;
}
Based on the notion that the retInstance comes from the RB
environment, we really should not unlock it because once the event/
interface method goes out of scope, RB will reduce the refcount on
the retInstance, right?
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>