开发者

How to release memory created from CFStringTokenizerCreate?

I use CFRelease to release the CFStringTokenizerRef obtained from CFStringTokenizerCreate call. But instruments is reporting memory leak at around this area. Am I missing something?


  CFStringTokenizerRef tokenRef = CFStringTokenizerCreate(NULL, 
                                   (CFStringRef)contents, 
                                   CFRangeMake(0, contents.length),
                                   kCFStringTokenizerUnitWordBoundary, 
                       开发者_如何学JAVA            NULL);

  CFStringTokenizerTokenType tokenType;
  // leak reported here
  while ((tokenType = CFStringTokenizerAdvanceToNextToken(tokenRef)) != kCFStringTokenizerTokenNone) 

}

CFRelease(tokenRef);


CFStringTokenizerCreate follows the Create Rule. So you are calling as expected.

There seems to be a missing brace after the while, this the CFRelease is not in the same scope. Is it a copy/paste error ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜