[cairo-commit] cairo/src cairo_font.c,1.13,1.14 cairo_ft_font.c,1.4,1.5 cairo_gstate.c,1.24,1.25 cairoint.h,1.34,1.35

Carl Worth commit at pdx.freedesktop.org
Thu Oct 30 10:55:06 PST 2003


Committed by: cworth

Update of /cvs/cairo/cairo/src
In directory pdx:/tmp/cvs-serv11706/src

Modified Files:
	cairo_font.c cairo_ft_font.c cairo_gstate.c cairoint.h 
Log Message:
A few cleanups to eliminate a memory leak.

Index: cairo_font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_font.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** cairo_font.c	24 Oct 2003 17:01:34 -0000	1.13
--- cairo_font.c	30 Oct 2003 18:55:04 -0000	1.14
***************
*** 42,53 ****
  		  const struct cairo_font_backend *backend)
  {
-     font->family = (unsigned char *) strdup (CAIRO_FONT_FAMILY_DEFAULT);
-     if (font->family == NULL)
- 	return CAIRO_STATUS_NO_MEMORY;
-     
      cairo_matrix_set_identity (&font->matrix);
      font->refcount = 1;
-     font->weight = CAIRO_FONT_WEIGHT_NORMAL;
-     font->slant = CAIRO_FONT_SLANT_NORMAL;
      font->backend = backend;
      
--- 42,47 ----
***************
*** 64,73 ****
  	return NULL;
      
-     if (font->family) {
- 	tmp = (unsigned char *) strdup ((char *) font->family);
- 	if (tmp == NULL)
- 	    return NULL;
-     }
-     
      newfont = font->backend->copy (font);
      if (newfont == NULL) {
--- 58,61 ----
***************
*** 77,107 ****
  
      newfont->refcount = 1;
-     newfont->family = tmp;
      cairo_matrix_copy(&newfont->matrix, &font->matrix);
-     newfont->slant = font->slant;
-     newfont->weight = font->weight;
      newfont->backend = font->backend;
      return newfont;
  }
  
- void
- _cairo_font_fini (cairo_font_t *font)
- {
-     if (font == NULL)
- 	return;
- 
-     if (--(font->refcount) > 0)
- 	return;
- 
-     if (font->family)
- 	free (font->family);
-     font->family = NULL;
-     
-     _cairo_matrix_fini (&font->matrix);
-     
-     if (font->backend->close)
- 	font->backend->close (font);
- }
- 
  cairo_status_t
  _cairo_font_scale (cairo_font_t *font, double scale)
--- 65,73 ----
***************
*** 198,202 ****
  cairo_font_destroy (cairo_font_t *font)
  {
!     _cairo_font_fini (font);
  }
  
--- 164,172 ----
  cairo_font_destroy (cairo_font_t *font)
  {
!     if (--(font->refcount) > 0)
! 	return;
! 
!     if (font->backend->destroy)
! 	font->backend->destroy (font);
  }
  

Index: cairo_ft_font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_ft_font.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** cairo_ft_font.c	28 Oct 2003 02:32:45 -0000	1.4
--- cairo_ft_font.c	30 Oct 2003 18:55:04 -0000	1.5
***************
*** 208,212 ****
  
  static void 
! _cairo_ft_font_close (cairo_font_t *font)
  {
      cairo_ft_font_t * ft_font = NULL;
--- 208,212 ----
  
  static void 
! _cairo_ft_font_destroy (cairo_font_t *font)
  {
      cairo_ft_font_t * ft_font = NULL;
***************
*** 601,604 ****
      create:                (void *) _cairo_ft_font_create,
      copy:                  (void *) _cairo_ft_font_copy,
!     close:                 (void *) _cairo_ft_font_close
  };
--- 601,604 ----
      create:                (void *) _cairo_ft_font_create,
      copy:                  (void *) _cairo_ft_font_copy,
!     destroy:               (void *) _cairo_ft_font_destroy
  };

Index: cairo_gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_gstate.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** cairo_gstate.c	28 Oct 2003 20:18:29 -0000	1.24
--- cairo_gstate.c	30 Oct 2003 18:55:04 -0000	1.25
***************
*** 148,152 ****
      _cairo_path_fini (&gstate->path);
    CLEANUP_FONT:
!     _cairo_font_fini (gstate->font);
    CLEANUP_DASHES:
      free (gstate->dash);
--- 148,152 ----
      _cairo_path_fini (&gstate->path);
    CLEANUP_FONT:
!     cairo_font_destroy (gstate->font);
    CLEANUP_DASHES:
      free (gstate->dash);
***************
*** 159,163 ****
  _cairo_gstate_fini (cairo_gstate_t *gstate)
  {
!     _cairo_font_fini (gstate->font);
  
      cairo_surface_destroy (gstate->surface);
--- 159,163 ----
  _cairo_gstate_fini (cairo_gstate_t *gstate)
  {
!     cairo_font_destroy (gstate->font);
  
      cairo_surface_destroy (gstate->surface);
***************
*** 1427,1431 ****
  {
      if (gstate->font != NULL)
! 	_cairo_font_fini (gstate->font);
  
      gstate->font = _cairo_font_create (family, slant, weight);
--- 1427,1431 ----
  {
      if (gstate->font != NULL)
! 	cairo_font_destroy (gstate->font);
  
      gstate->font = _cairo_font_create (family, slant, weight);
***************
*** 1479,1483 ****
  {
      if (gstate->font != NULL)    
! 	_cairo_font_fini (gstate->font);
      gstate->font = font;
      cairo_font_reference (gstate->font);
--- 1479,1483 ----
  {
      if (gstate->font != NULL)    
! 	cairo_font_destroy (gstate->font);
      gstate->font = font;
      cairo_font_reference (gstate->font);

Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** cairoint.h	28 Oct 2003 20:18:29 -0000	1.34
--- cairoint.h	30 Oct 2003 18:55:04 -0000	1.35
***************
*** 275,279 ****
      cairo_font_t *(*copy)            (cairo_font_t        *other);
  
!     void (*close)                    (cairo_font_t        *font);
    
  };
--- 275,279 ----
      cairo_font_t *(*copy)            (cairo_font_t        *other);
  
!     void (*destroy)		     (cairo_font_t        *font);
    
  };
***************
*** 400,407 ****
  struct cairo_font {
      int refcount;
-     unsigned char *family;
      cairo_matrix_t matrix;
-     cairo_font_slant_t slant;
-     cairo_font_weight_t weight;
      const struct cairo_font_backend *backend;
  };
--- 400,404 ----
***************
*** 790,796 ****
  _cairo_font_copy (cairo_font_t *font);
  
- extern void __internal_linkage
- _cairo_font_fini (cairo_font_t *font);
- 
  extern cairo_status_t __internal_linkage
  _cairo_font_scale (cairo_font_t *font, double scale);
--- 787,790 ----





More information about the cairo-commit mailing list