if (pattern->n_stops) free (pattern->stops);  if (pattern->type == CAIRO_PATTERN_SURFACE) {  if (pattern->source) { cairo_surface_set_matrix (pattern->source, &pattern->u.surface.save_matrix); cairo_surface_set_repeat (pattern->source, pattern->u.surface.save_repeat); cairo_surface_set_filter (pattern->source, pattern->u.surface.save_filter); } cairo_surface_destroy (pattern->u.surface.surface);
switch (pattern->type) { case CAIRO_PATTERN_SOLID: break; case CAIRO_PATTERN_SURFACE: { cairo_surface_pattern_t *fini = (cairo_surface_pattern_t *) pattern;  cairo_surface_destroy (fini->surface); } break; case CAIRO_PATTERN_LINEAR: case CAIRO_PATTERN_RADIAL: { cairo_gradient_pattern_t *fini = (cairo_gradient_pattern_t *) pattern;  if (fini->n_stops) free (fini->stops); } break;
_cairo_pattern_fini (cairo_pattern_t *pattern){    if (pattern->n_stops)	free (pattern->stops);        if (pattern->type == CAIRO_PATTERN_SURFACE) {	/* show_surface require us to restore surface matrix, repeat	   attribute, filter type */	if (pattern->source) {	    cairo_surface_set_matrix (pattern->source,				      &pattern->u.surface.save_matrix);	    cairo_surface_set_repeat (pattern->source,				      pattern->u.surface.save_repeat);	    cairo_surface_set_filter (pattern->source,				      pattern->u.surface.save_filter);	}	cairo_surface_destroy (pattern->u.surface.surface);    }        if (pattern->source)	cairo_surface_destroy (pattern->source);}