Managing FdoPtr Behaviors
The topics in this section describe several ways that you can manager FdoPtr behavior. For more information about managing FdoPtr behavior, see the related topics “FdoPtr <T> Class Template Reference” and “FdoIDisposable Class Reference” in the FDO Reference Help and The Essential FDO.
Do not chain calls. If you do, returned pointers will not be released. For example, given an FdoClassDefinition* pclassDef:
psz = pclassDef ->GetProperties()->GetItem(0)->GetName())
The above code would result in two memory leaks. Instead use:
FdoPropertyDefinitionCollection* pprops = pclassDef -> GetProperties();
FdoPropertyDefinition* ppropDef = pprops->GetItem(0);
psz = propDef->GetName();
ppropDef->Release();
pprops->Release();
FdoPtr<FdoPropertyDefinitionCollection> pprops = pclassDef-> GetProperties();
FdoPtr<FdoPropertyDefinition> ppropDef = pprops-> GetItem(0);
psz = propDef->GetName();
psz = FdoPtr <FdoPropertyDefinition> (FdoPtr <FdoPropertyDefinitionCollection>(pclassDef->GetProperties())-> GetItem(0))->GetName();
Assigning Return Pointer of an FDO Function Call to a Non-Smart Pointer
If you are assigning the return pointer of an FDO function call to a non-smart pointer, then you should assign that pointer to a FdoPtr. For example:
FdoLineString* P = gf.CreateLineString(...);
FdoPtr <FdoLineString> p2 = FDO_SAFE_ADDREF(p);