I am just trying to understand why the following code is causing a memory leak, and I have a strange feeling that I am not freeing the memory of the array correctly. This is a C function in the wider objective-c application, and I am not native to C ... I tried just using free () in an array, but I feel that this is not the whole story ...
Can someone look and see what I'm missing here. Thanks!
CFIndex theNumberOfSettings = 3; CTParagraphStyleSetting theSettings[3] = { {kCTParagraphStyleSpecifierAlignment, sizeof(CTTextAlignment), &alignment}, {kCTParagraphStyleSpecifierLineSpacing, sizeof(lineSpacing), &lineSpacing}, {kCTParagraphStyleSpecifierHeadIndent, sizeof(headIndent), &headIndent} }; CTParagraphStyleRef theParagraphRef = CTParagraphStyleCreate(theSettings, theNumberOfSettings); CFAttributedStringSetAttribute(attrString, CFRangeMake(0, CFAttributedStringGetLength(attrString)-1), kCTParagraphStyleAttributeName, theParagraphRef); CFRelease(theParagraphRef); free(theSettings);
source share