core-foundation

CGDataProvider works the first time, returns an empty image the second time

回眸只為那壹抹淺笑 提交于 2019-12-11 17:47:57
问题 I am trying to read the ARGB pixel data from a png image asset in my ios App. I am using CGDataProvider to get a CFDataRef as described here: http://developer.apple.com/library/ios/#qa/qa1509/_index.html It works perfectly the first time I use it on a certain image. But the second time I use it on THE SAME image, it returns a length 0 CFDataRef. Maybe I am not releasing something? Why would it do that? - (GLuint)initWithCGImage:(CGImageRef)newImageSource { CGDataProviderRef dataProvider;

CFNetwork HTTP timeout?

做~自己de王妃 提交于 2019-12-11 17:43:47
问题 I am looking for a way to add a timeout to a CFHTTP request. It seems like there should be a feature of the CFHTTPMessage or the CFReadStream object, but I can't find it. Do I have to roll my own timer on the run loop or something? (if so, any code for this?) Thanks! 回答1: My answer is outdated but I can't delete the accepted answer. 回答2: Try this, readStream is your CFReadStreamRef: #define _kCFStreamPropertyReadTimeout CFSTR("_kCFStreamPropertyReadTimeout") double to = 15; // 15s timeout

Memory Leak - Not Sure How/Where to CFRelease() CFSet

五迷三道 提交于 2019-12-11 16:44:44
问题 I'm yet again struggling with a memory leak, and need some help figuring this one out. I know (or am pretty sure) the CFSet(s) are the problem here. I assume I need to CFRelease() them, but am not sure how to accomplish this since I also need to return a CFSet in USBDeviceCount(). Any help would be appreciated! Thank you! Here's the code (which seemingly works great! except for the leaks): // New USB device has been added (callback function) static void Handle_DeviceMatchingCallback(void

CFLocaleCopyCurrent stale value

安稳与你 提交于 2019-12-11 14:46:14
问题 At my workplace, our app determines the locale of the user session by using a code that is similar to below (though there are various layers of code it passes through before it reaches here at the time of startup, so the problem is/may not evident by running the code below) #include <CoreFoundation/CoreFoundation.h> #include <iostream> #include <string> #include <vector> #include <memory> // Reference release struct reference_close { void operator()(const void *ref) const { CFRelease(static

CFString memory leak

天大地大妈咪最大 提交于 2019-12-11 13:43:09
问题 I have narrowed down a memory leak to the following code CFStringRef CFDataToString(CFDataRef data) { UInt8* buf = malloc(CFDataGetLength(data)); CFDataGetBytes(data, CFRangeMake(0, CFDataGetLength(data)), buf); CFMutableStringRef output = CFStringCreateMutable(kCFAllocatorDefault, CFDataGetLength(data) * 2); for(int i = 0; i < CFDataGetLength(data); i++) { CFStringAppendFormat(output, NULL, CFSTR("%02x"), buf[i]); } free(buf); CFRelease(data); return output; } Below is the code used in

How to set speech callback when using SpeakCFString?

ε祈祈猫儿з 提交于 2019-12-11 07:36:13
问题 I’m trying to use the C CoreFoundation interface to the Speech Synthesis Manager. How do you register a speech callback (such as kSpeechSpeechDoneCallBack or kSpeechTextDoneCallBack )? I know how to use the old deprecated SetSpeechInfo function; how do you do it with the new SetSpeechProperty? When I try to use it, it causes “Segmentation fault: 11” instead of calling the function I registered. According to Speech-Channel Properties, I think you’re supposed to pass in a long CFNumberRef whose

What is meant by NSXMLParserErrorDomain error 1549

本秂侑毒 提交于 2019-12-11 07:03:40
问题 I am trying to parse a xml document using NSXMLParser. Every time it result in NSXMLParserErrorDomain error 1549. I cant find any documentation regarding that error code. Any help. -Shakthi 回答1: This is probably a problem with resolving a DTD in the XML. Try disabling DTD downloading with this code: [parser setShouldResolveExternalEntities:NO] 来源: https://stackoverflow.com/questions/6028090/what-is-meant-by-nsxmlparsererrordomain-error-1549

Does CFHostGetAddressing() support ipv6 DNS entries?

馋奶兔 提交于 2019-12-11 03:38:14
问题 I am trying to use CFHostGetAddressing to do a simple DNS lookup. However, I notice that it returns an array of sockaddr structs, which I guess means it can only do IPV4. Is there a way to support DNS entries with IPV6 addresses in iOS? Perhaps a similar API that returns an array of sockaddr_storage structs? 回答1: The CFHostGetAddressing() documentation might be misleading, because struct sockaddr is a structure that covers all the common elements of the various socket addresses (IPv4, IPv6, .

Does the Core Foundation objects are automatically released by ARC or do we need manual memory management?

自古美人都是妖i 提交于 2019-12-11 03:33:52
问题 In my code am creating a Core Foundation object, and from the apple documentation i came to know that "The life span of a Core Foundation object is determined by its reference count" https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Articles/lifecycle.html So I highly doubt that whether the core foundation objects are released by ARC or do we need to release by writing CFRelease(myobject) Am using Xcode 6.4,and presently in my code am not using any

CGImageRef cg = [[UIImage imageNamed: Path] CGImage]; Requires a CGImageRelease(cg)'?

核能气质少年 提交于 2019-12-11 02:29:50
问题 I am trying to read the ARGB pixels from a an image asset in iOS. For that, I need a CGImageRef I can use to get its CGDataProvider . My question is, if I create a CGImageRef using: CGImageRef cg = [[UIImage imageNamed: Path] CGImage]; Will I eventually need to call CGImageRelease(cg) ? If I don't call CGImageRelease , will I have a memory leak? Another issue I am having is that reading the same file for a second time returns an empty image, which I suspect might be because I didn't call