[cfe-commits] r170478 - in /cfe/trunk/tools/libclang: CXComment.cpp SimpleFormatContext.h

Jordan Rose jordan_rose at apple.com
Tue Dec 18 16:31:05 PST 2012


On Dec 18, 2012, at 16:26 , jahanian <fjahanian at apple.com> wrote:

> 
> On Dec 18, 2012, at 4:10 PM, Jordan Rose <jordan_rose at apple.com> wrote:
> 
>> 
>>> if (!SFC) {
>>>   SFC = new SimpleFormatContext(Context.getLangOpts());
>>>   TU->FormatContext = SFC;
>>> -  }
>>> -  else if ((TU->FormatInMemoryUniqueId % 10) == 0) {
>>> +  } else if ((TU->FormatInMemoryUniqueId % 10) == 0) {
>>> +    // Delete after some number of iterators, so the buffers don't grow
>>> +    // too large.
>>>   delete SFC;
>>>   SFC = new SimpleFormatContext(Context.getLangOpts());
>> 
>> Hate to drag this out, but why not use an OwningPtr here? A little safer against future refactoring that misses a delete.
> 
> I a not sure I can use OwningPtr here. I am managing allocation and deletion of the object
> after a number of usages  myself. This does;t fit the usage for OwningPtr as I understand it.

Ah, I see…you're stealing the TU's format context, so it's not supposed to be freed at the end of the function. My mistake.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121218/2c80e4d2/attachment.html>


More information about the cfe-commits mailing list