Add comment pondering memory management semantics of cairo_current_target_surface.

NULL out pen->vertices after free.
NULL out durface->data after free.
This commit is contained in:
Carl Worth 2003-11-06 12:53:39 +00:00
parent 3262cd9f95
commit 7262e1554f
8 changed files with 34 additions and 2 deletions

View file

@ -1,3 +1,15 @@
2003-11-06 Carl Worth <cworth@east.isi.edu>
* src/cairo.h: Add comment pondering memory management semantics
of cairo_current_target_surface.
* src/cairo_pen.c (_cairo_pen_fini): NULL out pen->vertices after
free.
* src/cairo_image_surface.c
(_cairo_image_abstract_surface_destroy): NULL out durface->data
after free.
2003-11-04 Carl Worth <cworth@east.isi.edu>
* src/cairo_gstate.c (_cairo_gstate_set_target_surface): Enable

View file

@ -349,6 +349,11 @@ _cairo_gstate_current_target_surface (cairo_gstate_t *gstate)
if (gstate == NULL)
return NULL;
/* XXX: Do we want this?
if (gstate->surface)
_cairo_surface_reference (gstate->surface);
*/
return gstate->surface;
}

View file

@ -193,8 +193,10 @@ _cairo_image_abstract_surface_destroy (void *abstract_surface)
if (surface->ic_image)
IcImageDestroy (surface->ic_image);
if (surface->owns_data)
if (surface->owns_data) {
free (surface->data);
surface->data = NULL;
}
free (surface);
}

View file

@ -115,6 +115,8 @@ void
_cairo_pen_fini (cairo_pen_t *pen)
{
free (pen->vertices);
pen->vertices = NULL;
_cairo_pen_init_empty (pen);
}

View file

@ -490,6 +490,8 @@ cairo_current_miter_limit (cairo_t *cr);
extern void __external_linkage
cairo_current_matrix (cairo_t *cr, cairo_matrix_t *matrix);
/* XXX: Need to decide the memory mangement semantics of this
function. Should it reference the surface again? */
extern cairo_surface_t * __external_linkage
cairo_current_target_surface (cairo_t *cr);

View file

@ -349,6 +349,11 @@ _cairo_gstate_current_target_surface (cairo_gstate_t *gstate)
if (gstate == NULL)
return NULL;
/* XXX: Do we want this?
if (gstate->surface)
_cairo_surface_reference (gstate->surface);
*/
return gstate->surface;
}

View file

@ -193,8 +193,10 @@ _cairo_image_abstract_surface_destroy (void *abstract_surface)
if (surface->ic_image)
IcImageDestroy (surface->ic_image);
if (surface->owns_data)
if (surface->owns_data) {
free (surface->data);
surface->data = NULL;
}
free (surface);
}

View file

@ -115,6 +115,8 @@ void
_cairo_pen_fini (cairo_pen_t *pen)
{
free (pen->vertices);
pen->vertices = NULL;
_cairo_pen_init_empty (pen);
}