I have created CGDataProviderRef, and one of parameters is array of pixels. When I release provider, do i also have to free memory, or is provider doing it itself?
pixels = (Byte *) malloc([data length] * sizeof (Byte));
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, pixels, [data length], NULL);
Basically, do i have to call:
[provider release];
[free pixels];
When you already have your data in an NSData object you can instead use CGDataProviderCreateWithCFData, so you don’t have to malloc and copy the pixels.
If you insist on using a malloc’d array you can provide a callback that is called when the data provider is released like this: