Surface data memory management

Mar 19, 2012 at 9:02am

Surface data memory management

Hi there,

I am writing an UI external where I compute a surface to display in the paint method.
The code is something like:

unsigned char *data = (unsigned char *)sysmem_newptr(bytecount);
if (data) {

    // compute surface

    if (x->surface) {
    x->surface = jgraphics_image_surface_create_for_data(data, JGRAPHICS_FORMAT_ARGB32,
                                                         width, height, linestride,
                                                         (method)sysmem_freeptr, data);

Everytime the object is resized this code gets called to re-compute the surface at different sizes.

According to my understanding, when I call jgraphics_surface_destroy() it will free the memory associated with the surface AND with the data pointer as well. So am I correct in assuming that with the above code I will not need to manage the memory of the data pointer, nor I will need to save it inside my object struct? Comments?


- Luigi


You must be logged in to reply to this topic.