typedef结构的内存泄漏 [英] Memory Leaks for typedef struct

查看:94
本文介绍了typedef结构的内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试消除内存泄漏.下面是我的代码.

I m trying to remove memory leaks. Below is my code.

currentTime = CFAbsoluteTimeGetCurrent();

CFTimeZoneRef currentTimeZone = CFTimeZoneCopyDefault();

todaysDate = CFAbsoluteTimeGetGregorianDate(currentTime, currentTimeZone);


[currentTimeZone release];
currentTimeZone = nil;

警告::/myclass.m:87:警告:接收器类型'CFTimeZoneRef'无效

Warning:::/myclass.m:87: warning: invalid receiver type 'CFTimeZoneRef'

如何释放typedef const结构的内存?

how to release memory for typedef const struct?

推荐答案

对于CFxxxCopyxxx,您应该使用CFRelease.

CFRelease(currentTimeZone);

CoreFoundation 类是

There are CoreFoundation classes that are Toll-Free bridged and your original statement was not leaking but just needed a cast. I would still recommend using CFRelease since you were working directly with CoreFoundation.

[(NSTimeZone*)currentTimeZone release];

这篇关于typedef结构的内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆