From 0aa96bfc7abe18889cd85bfaa05b05d53e572bb1 Mon Sep 17 00:00:00 2001 From: Jamey Sharp Date: Fri, 15 Sep 2006 00:39:51 -0700 Subject: [PATCH] Convert connection functions to return error objects. --- src/xcb_conn.c | 6 ++++-- src/xcb_util.c | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/xcb_conn.c b/src/xcb_conn.c index b0d727b..0176524 100644 --- a/src/xcb_conn.c +++ b/src/xcb_conn.c @@ -44,6 +44,8 @@ typedef struct { CARD16 length; } XCBSetupGeneric; +static const int error_connection = 1; + static int set_fd_flags(const int fd) { long flags = fcntl(fd, F_GETFL, 0); @@ -199,7 +201,7 @@ XCBConnection *XCBConnectToFD(int fd, XCBAuthInfo *auth_info) c = calloc(1, sizeof(XCBConnection)); if(!c) - return 0; + return (XCBConnection *) &error_connection; c->fd = fd; @@ -215,7 +217,7 @@ XCBConnection *XCBConnectToFD(int fd, XCBAuthInfo *auth_info) )) { XCBDisconnect(c); - return 0; + return (XCBConnection *) &error_connection; } return c; diff --git a/src/xcb_util.c b/src/xcb_util.c index 3bdcd36..d93353b 100644 --- a/src/xcb_util.c +++ b/src/xcb_util.c @@ -45,6 +45,8 @@ #include "xcbext.h" #include "xcbint.h" +static const int error_connection = 1; + int XCBPopcount(CARD32 mask) { unsigned long y; @@ -212,11 +214,11 @@ XCBConnection *XCBConnect(const char *displayname, int *screenp) XCBAuthInfo auth; if(!XCBParseDisplay(displayname, &host, &display, screenp)) - return 0; + return (XCBConnection *) &error_connection; fd = _xcb_open(host, display); free(host); if(fd == -1) - return 0; + return (XCBConnection *) &error_connection; _xcb_get_auth_info(fd, &auth); c = XCBConnectToFD(fd, &auth); @@ -231,11 +233,11 @@ XCBConnection *XCBConnectToDisplayWithAuthInfo(const char *displayname, XCBAuthI char *host; if(!XCBParseDisplay(displayname, &host, &display, screenp)) - return 0; + return (XCBConnection *) &error_connection; fd = _xcb_open(host, display); free(host); if(fd == -1) - return 0; + return (XCBConnection *) &error_connection; return XCBConnectToFD(fd, auth); } -- 2.34.1