From c6dcfb9fbce489dd4c027a8fafe75a21b8898c5f Mon Sep 17 00:00:00 2001 From: eknauel Date: Fri, 24 Oct 2003 06:27:02 +0000 Subject: [PATCH] fixed scx_XftColorAllocValue() and its scheme counterpart --- c/libs/xft.c | 13 +++++++------ scheme/libs/xft.scm | 16 ++++++++++------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/c/libs/xft.c b/c/libs/xft.c index ad32cf9..0d8b8e3 100644 --- a/c/libs/xft.c +++ b/c/libs/xft.c @@ -422,15 +422,16 @@ s48_value scx_XftColorAllocValue(s48_value sdpy, s48_value svisual, s48_value scolormap, s48_value sxrendercolor) { s48_value res = S48_FALSE; - XftColor *xftcolor = NULL; - Bool b; + XftColor *xftcolor; + Bool b = False; S48_DECLARE_GC_PROTECT(5); S48_GC_PROTECT_5(res, sdpy, svisual, scolormap, sxrendercolor); - b = XftColorAllocValue(scx_extract_display(sdpy), scx_extract_visual(svisual), - scx_extract_colormap(scolormap), - scx_extract_xrendercolor(sxrendercolor), - xftcolor); + if ((xftcolor = (XftColor *) calloc(1, sizeof(XftColor))) != NULL) + b = XftColorAllocValue(scx_extract_display(sdpy), scx_extract_visual(svisual), + scx_extract_colormap(scolormap), + scx_extract_xrendercolor(sxrendercolor), + xftcolor); res = s48_list_2(b ? S48_TRUE : S48_FALSE, b ? scx_enter_xftcolor(xftcolor) : S48_FALSE); S48_GC_UNPROTECT(); diff --git a/scheme/libs/xft.scm b/scheme/libs/xft.scm index e89e085..f440845 100644 --- a/scheme/libs/xft.scm +++ b/scheme/libs/xft.scm @@ -157,12 +157,16 @@ #f)))) (define (scx-xft-color-alloc-value display visual colormap xrendercolor) - (let ((xft-color (scx-xft-color-alloc-value-internal display visual colormap xrendercolor))) - (set-xft-color-display! xft-color display) - (set-xft-color-visual! xft-color visual) - (set-xft-color-colormap! xft-color colormap) - (add-finalizer! xft-color xft-color-finalizer) - xft-color)) + (call-with-values + (lambda () + (apply values + (scx-xft-color-alloc-value-internal display visual colormap xrendercolor))) + (lambda (success? xft-color) + (set-xft-color-display! xft-color display) + (set-xft-color-visual! xft-color visual) + (set-xft-color-colormap! xft-color colormap) + (add-finalizer! xft-color xft-color-finalizer) + xft-color))) (define (xft-color-finalizer xft-color) (scx-xft-color-free (xft-color-display xft-color)