<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>Source in question: <span class="Apple-style-span" style="font-family: Arial; font-size: 12px; ">sfx2/source/doc/doctemplates.cxx</span></div><div><span class="Apple-style-span" style="font-family: Arial; font-size: 12px; "><br></span></div><div><span class="Apple-style-span" style="font-family: Arial; font-size: 12px; ">The code looks like this:</span></div><div><span class="Apple-style-span" style="font-family: Arial; font-size: 12px; "><div><br></div><div>//-----------------------------------------------------------------------------</div><div><br></div></span></div><div><span class="Apple-style-span" style="font-family: Arial; font-size: 12px; "><div>struct NamePair_Impl</div><div>{</div><div> OUString maShortName;</div><div> OUString maLongName;</div><div>};</div><div><br></div><div><div>DECLARE_LIST( NameList_Impl, NamePair_Impl* )</div></div><div><br></div><div><div>class SfxDocTplService_Impl</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>...</div><div> NameList_Impl<span class="Apple-tab-span" style="white-space:pre">                                </span>maNames;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>...</div><div> void<span class="Apple-tab-span" style="white-space:pre">                                                </span>readFolderList();</div><div> OUString<span class="Apple-tab-span" style="white-space:pre">                                        </span>getLongName( const OUString& rShortName );</div></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>...</div><div>}</div><div><br></div><div><div>void SfxDocTplService_Impl::readFolderList()</div><div>{</div><div> SolarMutexGuard aGuard;</div><div><br></div><div> ResStringArray aShortNames( SfxResId( TEMPLATE_SHORT_NAMES_ARY ) );</div><div> ResStringArray aLongNames( SfxResId( TEMPLATE_LONG_NAMES_ARY ) );</div><div><br></div><div> NamePair_Impl* pPair;</div><div><br></div><div> USHORT nCount = (USHORT)( Min( aShortNames.Count(), aLongNames.Count() ) );</div><div><br></div><div> for ( USHORT i=0; i<nCount; i++ )</div><div> {</div><div> pPair = new NamePair_Impl;</div><div> pPair->maShortName = aShortNames.GetString( i );</div><div> pPair->maLongName = aLongNames.GetString( i );</div><div><br></div><div> maNames.Insert( pPair, LIST_APPEND );</div><div> }</div><div>}</div></div><div><br></div><div><div>OUString SfxDocTplService_Impl::getLongName( const OUString& rShortName )</div><div>{</div><div> OUString aRet;</div><div> NamePair_Impl *pPair = maNames.First();</div><div><br></div><div> while ( pPair )</div><div> {</div><div> if ( pPair->maShortName == rShortName )</div><div> {</div><div> aRet = pPair->maLongName;</div><div> break;</div><div> }</div><div> else</div><div> pPair = maNames.Next();</div><div> }</div><div><br></div><div> if ( !aRet.getLength() )</div><div> aRet = rShortName;</div><div><br></div><div> return aRet;</div><div>}</div></div><div><br></div><div>//-----------------------------------------------------------------------------</div><div><br></div><div>No where in the code can I see where maNames gets cleanup up. The only destructor is in the base class which just cleans up the list memory and doesn't free the NamePair_Impl memory.</div><div><br></div><div><div>Container::~Container()</div><div>{</div><div> DBG_DTOR( Container, DbgCheckContainer );</div><div><br></div><div> // Alle Bloecke loeschen</div><div> CBlock* pBlock = pFirstBlock;</div><div> while ( pBlock )</div><div> {</div><div> CBlock* pTemp = pBlock->GetNextBlock();</div><div> delete pBlock;</div><div> pBlock = pTemp;</div><div> }</div><div>}</div><div><br></div></div><div>I'm thinking of just adding code to ~SfxDocTplService_Impl() to free the NamePair_Impl items.</div><div><br></div><div>What I'd like to know is the following:</div><div><br></div><div>1. Am I reading this correctly?</div><div>2. Where is this uses, so I can test my changes? (I'm converting the above code to use a vector<>)</div><div><br></div><div>The use path is:</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>NamePair_Impl</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>SfxDocTplService_Impl</div><div><span class="Apple-tab-span" style="white-space:pre">        Updater_Impl</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-tab-span" style="white-space:pre">        SfxDocTplService_Impl</span> </span>(yes, it's a circular definition)</div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-tab-span" style="white-space:pre">        SfxDocTplService</span></span></span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-tab-span" style="white-space:pre"><br></span></span></span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-tab-span" style="white-space:pre">        SfxDocTplService</span> </span>i</span>s</span> registered as com.sun.star.frame.DocumentTemplates</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>which gets used in:</div><div><span class="Apple-tab-span" style="white-space:pre">                svtools/source/contnr/templwin.cxx</span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-tab-span" style="white-space:pre">                sd/source/ui/dlg/TemplateScanner.cxx</span></span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-tab-span" style="white-space:pre"><br></span></span></div><div><span class="Apple-tab-span" style="white-space:pre"><span class="Apple-tab-span" style="white-space:pre">J</span>o</span>e P.</div></span></div></body></html>