I write a function to calculate the end index of attributtedString in a rect,
But it seems some memory leak, Please help me to fix it.
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attributtedString);
CGMutablePathRef path = CGPathCreateMutable();
CGPathAddRect(path, NULL, rect);
CTFrameRef frame = CTFramesetterCreateFrame(framesetter, CFRangeMake(currentIndex, 0), path, NULL);
CFRange frameRange = CTFrameGetVisibleStringRange(frame);
endIndex += frameRange.length;
CFRelease(frame);
CFRelease(path);
CFRelease(framesetter);
thanks in advance.
There is no memory leak in the above example. As far as we can see you are releasing everything properly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With