malloc: *** error for object 0x1ecc0eb0: pointer being freed was not allocated
2014-08-28 17:22
387 查看
当在做Unity与XCode之间通信时:
XCode中的代码:
或者
这上面两种情况下XCode运行均报错如下:
![](http://img.blog.csdn.net/20140828171300171?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvd3VtaW5nMjIyMjI=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
解决方法,改变代码为:
XCode中的代码:
extern "C" { const char* getWeiboAppInstallUrl() { NSString *str = [[NSString alloc] initWithCString:"Sheldon" encoding:NSStringEncodingConversionAllowLossy]; return [str UTF8String]; } }
或者
extern "C" { const char* getWeiboAppInstallUrl() { const char * a = "Sheldon"; return a; } }
这上面两种情况下XCode运行均报错如下:
解决方法,改变代码为:
extern "C" { char * getWeiboAppInstallUrl() { NSString * str = [[NSString alloc]initWithString:@"Sheldon"]; char * x = (char *)malloc(strlen([str UTF8String]) + 1); strcpy(x, [str UTF8String]); return x; } }
相关文章推荐
- Unity 调用oc报错:malloc: *** error for object 0x1ecc0eb0: pointer being freed was not allocated
- 内存耗尽产生的crash: malloc: *** error for object 0x: pointer being reallocated was not allocated
- malloc: *** error for object xx: pointer being freed was not allocate的问题的解决方法之一
- 为磁盘目录授权出现:malloc: *** error for object xx: pointer being freed was not allocate问题解决
- malloc: *** error: incorrect checksum for freed object - object was probably modified after being freed
- xcode 报错 malloc: *** error for object 0x6c3c5a4: incorrect checksum for freed object - object was probably modified after being freed. *** set a breakpoint in malloc_error_break to debug------d
- Python:malloc: *** error for object: incorrect checksum for freed object - object was
- Mac终端出现“terminal pointer being freed was not allocated…”解决办法
- ios 开发中出现的 pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug
- "malloc: * error for object 0x17415d0c0: Invalid pointer dequeued from free list * set a breakpoint in malloc_error_break to debug";
- malloc: *** error for object 0x6080000bd200: Invalid pointer dequeued from free list *** set a breakpoint in malloc_error_break to debug
- malloc: *** error for object 0x6080000bd200: Invalid pointer dequeued from free list *** set a breakpoint in malloc_error_break to debug
- Xcode 7 warnings: object file was built for newer iOS version than being linked
- What happened if i delete a pointer which was not allocated dynamically?
- android Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine.
- 问题3-Error occurred during initialization of VM Could not reserve enough space for object heap
- -observeValueForKeyPath:ofObject:change:context: message was received but not handled.
- fisheye Error occurred during initialization of VM Could not reserve enough space for object heap 问题解决!
- What happened if i delete a pointer which was not allocated dynamically?
- Error:Unable to start the daemon process: could not reserve enough space for object heap.