Tri*_*cky 4 c iphone cocoa objective-c
我只是想弄清楚为什么以下代码泄漏内存,我有一种有趣的感觉,我没有正确释放阵列内存.这是一个更广泛的Objective-c应用程序中的C函数,我不是C的原生...我曾尝试在数组上使用free(),但感觉这不是整个故事......
有人可以看一看,看看我在这里缺少什么.谢谢!
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);
Run Code Online (Sandbox Code Playgroud)
Bri*_*ndy 12
您没有释放未在堆上分配的内存.