[cairo-commit] 2 commits - src/cairo-colr-glyph-render.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jan 17 20:26:52 UTC 2023


 src/cairo-colr-glyph-render.c |   26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

New commits:
commit 2c557d7ceac792bff21d946b288f6fc2d54cb73a
Merge: f133b4be1 9e6c1e479
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Tue Jan 17 20:26:50 2023 +0000

    Merge branch 'colrv1-stack-variable' into 'master'
    
    [COLRv1] Allocate context variable on the stack
    
    See merge request cairo/cairo!410

commit 9e6c1e479f45bc185b67d0019e6454cbcc9b2a33
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jan 17 07:58:38 2023 -0700

    [COLRv1] Allocate context variable on the stack

diff --git a/src/cairo-colr-glyph-render.c b/src/cairo-colr-glyph-render.c
index 2388d9e02..d6cf8ed0a 100644
--- a/src/cairo-colr-glyph-render.c
+++ b/src/cairo-colr-glyph-render.c
@@ -1190,7 +1190,7 @@ _cairo_render_colr_v1_glyph (FT_Face               face,
                              cairo_t              *cr)
 {
     cairo_status_t status = CAIRO_STATUS_SUCCESS;
-    cairo_colr_glyph_render_t *colr_render = NULL;
+    cairo_colr_glyph_render_t colr_render;
     FT_Color *palette = NULL;
     FT_Palette_Data palette_data;
 
@@ -1198,12 +1198,6 @@ _cairo_render_colr_v1_glyph (FT_Face               face,
     printf ("_cairo_render_colr_glyph  glyph index: %ld\n", glyph);
 #endif
 
-    colr_render = _cairo_malloc (sizeof (cairo_colr_glyph_render_t));
-    if (unlikely (colr_render == NULL)) {
-	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
-	goto cleanup;
-    }
-
     if (FT_Palette_Data_Get (face, &palette_data) == 0 && palette_data.num_palettes > 0) {
 	if (palette_index >= palette_data.num_palettes)
 	    palette_index = CAIRO_COLOR_PALETTE_DEFAULT;
@@ -1212,22 +1206,18 @@ _cairo_render_colr_v1_glyph (FT_Face               face,
 	    palette = NULL;
     }
 
-    colr_render->face = face;
-    colr_render->palette = palette;
-    colr_render->num_palette_entries = palette_data.num_palette_entries;
-    colr_render->foreground_color = cairo_pattern_reference (cairo_get_source (cr));
-    colr_render->level = 0;
+    colr_render.face = face;
+    colr_render.palette = palette;
+    colr_render.num_palette_entries = palette_data.num_palette_entries;
+    colr_render.foreground_color = cairo_pattern_reference (cairo_get_source (cr));
+    colr_render.level = 0;
 
-    status = draw_colr_glyph (colr_render,
+    status = draw_colr_glyph (&colr_render,
 			      glyph,
 			      FT_COLOR_INCLUDE_ROOT_TRANSFORM,
 			      cr);
   
-  cleanup:
-    cairo_pattern_destroy (colr_render->foreground_color);
-
-    if (colr_render)
-	free (colr_render);
+    cairo_pattern_destroy (colr_render.foreground_color);
 
     return status;
 }


More information about the cairo-commit mailing list