From 61d552a8605eb3fd9069933932db7bb7641cc2a8 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 14 May 2008 15:22:31 +0200 Subject: [PATCH] [draw] Inline draw_context_delete() and check that it's != NULL Signed-off-by: Julien Danjou --- common/draw.c | 12 ------------ common/draw.h | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/common/draw.c b/common/draw.c index 9636342e..f85814a1 100644 --- a/common/draw.c +++ b/common/draw.c @@ -135,18 +135,6 @@ draw_context_new(xcb_connection_t *conn, int phys_screen, int width, int height, return d; }; -/** Delete a draw context - * \param ctx draw_context_t to delete - */ -void -draw_context_delete(draw_context_t **ctx) -{ - g_object_unref((*ctx)->layout); - cairo_surface_destroy((*ctx)->surface); - cairo_destroy((*ctx)->cr); - p_delete(ctx); -} - /** Create a new Pango font * \param conn Connection ref * \param fontname Pango fontname (e.g. [FAMILY-LIST] [STYLE-OPTIONS] [SIZE]) diff --git a/common/draw.h b/common/draw.h index cdc53eb5..a3c6b8db 100644 --- a/common/draw.h +++ b/common/draw.h @@ -124,7 +124,20 @@ typedef struct } draw_context_t; draw_context_t *draw_context_new(xcb_connection_t *, int, int, int, xcb_drawable_t); -void draw_context_delete(draw_context_t **); +/** Delete a draw context + * \param ctx draw_context_t to delete + */ +static inline void +draw_context_delete(draw_context_t **ctx) +{ + if(*ctx) + { + g_object_unref((*ctx)->layout); + cairo_surface_destroy((*ctx)->surface); + cairo_destroy((*ctx)->cr); + p_delete(ctx); + } +} font_t *draw_font_new(xcb_connection_t *, int, char *); void draw_font_delete(font_t **);