Potential leak of memory pointed to by 'machine'

时间:2015-03-24 23:16:47   收藏:0   阅读:711

技术分享


Potential leak of memory pointed to by ‘machine‘

NSString * zipPath=[NSString stringWithFormat:@"{TIME=%@",[self getChuo_time]];size_t size;
   
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
   
char *machine = (char*)malloc(size);
   
sysctlbyname("hw.machine", machine, &size, NULL, 0);
   
NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];//手机型号
    free(machine);


malloc  和  free是必须配对儿使用的。要不就是内存泄漏




原文:http://blog.csdn.net/u010241322/article/details/44595761

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!