From 60b0a34d8a0fa605e80b6f15d5a8174d9c211b44 Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Mon, 7 May 2018 17:11:24 -0700 Subject: [PATCH cairo] boilerplate: Use _cairo_malloc instead of malloc This changes most instances of malloc() calls to use Cairo's safer _cairo_malloc(). The malloc() call in the implementation of boilerplate's xmalloc() is not changed since it already includes a size=0 check. Signed-off-by: Bryce Harrington --- boilerplate/cairo-boilerplate-cogl.c | 5 +++-- boilerplate/cairo-boilerplate-vg.c | 3 ++- boilerplate/cairo-boilerplate-win32-printing.c | 3 ++- boilerplate/cairo-boilerplate-xcb.c | 3 ++- boilerplate/cairo-boilerplate-xlib.c | 3 ++- boilerplate/cairo-boilerplate.c | 7 ++++--- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/boilerplate/cairo-boilerplate-cogl.c b/boilerplate/cairo-boilerplate-cogl.c index e39ad33..14c8ecb 100644 --- a/boilerplate/cairo-boilerplate-cogl.c +++ b/boilerplate/cairo-boilerplate-cogl.c @@ -31,6 +31,7 @@ */ #include "cairo-boilerplate-private.h" +#include "cairo-malloc-private.h" #include #include @@ -92,7 +93,7 @@ _cairo_boilerplate_cogl_create_offscreen_color_surface (const char *name, -1, 100); cogl_pop_framebuffer (); - closure = malloc (sizeof (cogl_closure_t)); + closure = _cairo_malloc (sizeof (cogl_closure_t)); *abstract_closure = closure; closure->device = device; closure->fb = fb; @@ -138,7 +139,7 @@ _cairo_boilerplate_cogl_create_onscreen_color_surface (const char *name, -1, 100); cogl_pop_framebuffer (); - closure = malloc (sizeof (cogl_closure_t)); + closure = _cairo_malloc (sizeof (cogl_closure_t)); *abstract_closure = closure; closure->device = device; closure->fb = fb; diff --git a/boilerplate/cairo-boilerplate-vg.c b/boilerplate/cairo-boilerplate-vg.c index 6927657..4ea6ba4 100644 --- a/boilerplate/cairo-boilerplate-vg.c +++ b/boilerplate/cairo-boilerplate-vg.c @@ -31,6 +31,7 @@ */ #include "cairo-boilerplate-private.h" +#include "cairo-malloc-private.h" #include @@ -105,7 +106,7 @@ _cairo_boilerplate_vg_create_surface_glx (const char *name, cairo_vg_context_t *context; vg_closure_glx_t *vgc; - vgc = malloc (sizeof (vg_closure_glx_t)); + vgc = _cairo_malloc (sizeof (vg_closure_glx_t)); *closure = vgc; if (width == 0) diff --git a/boilerplate/cairo-boilerplate-win32-printing.c b/boilerplate/cairo-boilerplate-win32-printing.c index 625d52c..f62e5f5 100644 --- a/boilerplate/cairo-boilerplate-win32-printing.c +++ b/boilerplate/cairo-boilerplate-win32-printing.c @@ -35,6 +35,7 @@ #endif #include "cairo-boilerplate-private.h" +#include "cairo-malloc-private.h" #if CAIRO_CAN_TEST_WIN32_PRINTING_SURFACE @@ -131,7 +132,7 @@ create_printer_dc (win32_target_closure_t *ptc) ptc->dc = NULL; GetDefaultPrinter (NULL, &size); - printer_name = malloc (size); + printer_name = _cairo_malloc (size); if (printer_name == NULL) return; diff --git a/boilerplate/cairo-boilerplate-xcb.c b/boilerplate/cairo-boilerplate-xcb.c index cc9b422..de9583f 100644 --- a/boilerplate/cairo-boilerplate-xcb.c +++ b/boilerplate/cairo-boilerplate-xcb.c @@ -25,6 +25,7 @@ */ #include "cairo-boilerplate-private.h" +#include "cairo-malloc-private.h" #include @@ -206,7 +207,7 @@ _cairo_boilerplate_xcb_create_similar (cairo_surface_t *other, xcb_render_pictforminfo_t *render_format; int depth; - similar = malloc (sizeof (*similar)); + similar = _cairo_malloc (sizeof (*similar)); switch (content) { default: diff --git a/boilerplate/cairo-boilerplate-xlib.c b/boilerplate/cairo-boilerplate-xlib.c index f3d5598..5d2498c 100644 --- a/boilerplate/cairo-boilerplate-xlib.c +++ b/boilerplate/cairo-boilerplate-xlib.c @@ -26,6 +26,7 @@ #include "cairo-boilerplate-private.h" #include "cairo-boilerplate-xlib.h" +#include "cairo-malloc-private.h" #include #if CAIRO_HAS_XLIB_XRENDER_SURFACE @@ -244,7 +245,7 @@ _cairo_boilerplate_xlib_create_similar (cairo_surface_t *other, struct similar *similar; cairo_surface_t *surface; - similar = malloc (sizeof (*similar)); + similar = _cairo_malloc (sizeof (*similar)); similar->dpy = cairo_xlib_surface_get_display (other); switch (content) { diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c index 4804dea..904683a 100644 --- a/boilerplate/cairo-boilerplate.c +++ b/boilerplate/cairo-boilerplate.c @@ -28,6 +28,7 @@ #include "cairo-boilerplate-private.h" #include "cairo-boilerplate-scaled-font.h" +#include "cairo-malloc-private.h" #include @@ -183,7 +184,7 @@ _cairo_boilerplate_image_create_similar (cairo_surface_t *other, } stride = cairo_format_stride_for_width(format, width); - ptr = malloc (stride* height); + ptr = _cairo_malloc (stride * height); surface = cairo_image_surface_create_for_data (ptr, format, width, height, stride); @@ -232,7 +233,7 @@ _cairo_boilerplate_image16_create_similar (cairo_surface_t *other, } stride = cairo_format_stride_for_width(format, width); - ptr = malloc (stride* height); + ptr = _cairo_malloc (stride * height); surface = cairo_image_surface_create_for_data (ptr, format, width, height, stride); @@ -245,7 +246,7 @@ static char * _cairo_boilerplate_image_describe (void *closure) { char *s; - + xasprintf (&s, "pixman %s", pixman_version_string ()); return s; -- 2.7.4