I am creating a bitmap context, and in my code there is the following:
bitmapData = malloc(bitmapByteCount); context = CGBitmapContextCreate (bitmapData, pixelsWidth, pixelsHeight, 8, // bits per component bitmapBytesPerRow, colorSpace, kCGImageAlphaPremultipliedFirst);
before the method returns a CGContextRef object, I think I should free bitmapData. Can I call safely free(bitmapData)before returning context?
free(bitmapData)
context
The documentation for CGBitmapContextCreateindicates the following:
CGBitmapContextCreate
In iOS 4.0 and later and Mac OS X v10.6 and later, you can pass NULL if you want quartz to allocate memory for the bitmap. This frees you from managing your own memory, which reduces memory leak problems.
NULL malloc'd, .
, CGBitmapContextCreate "create" , . - CFRelease().
CFRelease()
Jasarien , iOS 4.0 . , .
, . , bitmapData, Bad Things. bitmapData CFRelease . CGBitmapContextCreateImage CGImage , ... , CGImage .
, , , . , , , . , bitmapData ivars. , , , bitmapContext.
NULL bitmapData, iOS 4.0 . 4.0+ NULL, , , , CFRelease , .
Source: https://habr.com/ru/post/1766172/More articles:What does this value mean in a class definition? - oopWhat is the meaning of $ this - variablesHow to "bind" an element buffer array to a vertex array object using direct access to content? - openglHTML5 + CSS and setting the width - cssInstall VC ++ Runtime 64-bit if the system is 64-bit - visual-studio-2010IE9 Beta support for local storage - local-storageHow can netTcpBinding be slower than wsHttpBinding? - wcfreverse engineering tools for java - javaCan I use gitg to view changes in only one file / directory? - gitHow to list all columns of a given SQL query - sql-serverAll Articles