<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Dec 18, 2012, at 16:26 , jahanian <<a href="mailto:fjahanian@apple.com">fjahanian@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br>On Dec 18, 2012, at 4:10 PM, Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>> wrote:<br><br><blockquote type="cite"><br><blockquote type="cite"> if (!SFC) {<br>   SFC = new SimpleFormatContext(Context.getLangOpts());<br>   TU->FormatContext = SFC;<br>-  }<br>-  else if ((TU->FormatInMemoryUniqueId % 10) == 0) {<br>+  } else if ((TU->FormatInMemoryUniqueId % 10) == 0) {<br>+    // Delete after some number of iterators, so the buffers don't grow<br>+    // too large.<br>   delete SFC;<br>   SFC = new SimpleFormatContext(Context.getLangOpts());<br></blockquote><br>Hate to drag this out, but why not use an OwningPtr here? A little safer against future refactoring that misses a delete.<br></blockquote><br>I a not sure I can use OwningPtr here. I am managing allocation and deletion of the object<br>after a number of usages  myself. This does;t fit the usage for OwningPtr as I understand it.<br></blockquote></div><br><div>Ah, I see…you're stealing the TU's format context, so it's <i>not</i> supposed to be freed at the end of the function. My mistake.</div></body></html>