views:

83

answers:

1

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, 
                                   NULL);

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

}

CFRelease(tokenRef);
A: 

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 ?

Laurent Etiemble
The code as presented has a syntax error, as `while` requires a statement following the condition, and the code shown has none (condition immediately followed by closing brace of outer compound statement or function/method body). I think it is too early to assess what scope anything is in until the code shown is valid.
Peter Hosey