commit 7b3ac6b389dd1332b0bf3d907a964ba1ee8fb067 Author: Joshua Phillips Date: Thu Sep 23 12:08:08 2010 +0100 Free resources after a connection error. - Add is_open field of xcb_connection_t. is_open is set to 1 for open connections that require clean-up. - error_connection is now an xcb_connection_t with has_error and is_open always set to 1 and 0 respectively. diff --git a/src/xcb_conn.c b/src/xcb_conn.c index f2a2636..3318526 100644 --- a/src/xcb_conn.c +++ b/src/xcb_conn.c @@ -58,7 +58,10 @@ typedef struct { uint16_t length; } xcb_setup_generic_t; -static const int error_connection = 1; +static const xcb_connection_t error_connection = { + 1, /* has_error */ + 0, /* is_open */ +}; static int set_fd_flags(const int fd) { @@ -272,6 +275,7 @@ xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info) } c->fd = fd; + c->is_open = 1; if(!( set_fd_flags(fd) && @@ -293,7 +297,7 @@ xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info) void xcb_disconnect(xcb_connection_t *c) { - if(c->has_error) + if (!c->is_open) return; free(c->setup); diff --git a/src/xcbint.h b/src/xcbint.h index f07add8..bbaa460 100644 --- a/src/xcbint.h +++ b/src/xcbint.h @@ -176,6 +176,7 @@ void _xcb_ext_destroy(xcb_connection_t *c); struct xcb_connection_t { int has_error; + int is_open; /* constant data */ xcb_setup_t *setup;