X-Git-Url: http://git.demorecorder.com/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fxcb_ext.c;h=831f283810c26bcf37f8647195a639a3745240c5;hb=cca607409068ad0948e7283fb8d0465cabc51686;hp=373251583e7e7a6e7ac23b7d8cfdb95f5135821f;hpb=7f71bf9c0f30536e85907b2c991cb7001861e1d3;p=free-sw%2Fxcb%2Flibxcb diff --git a/src/xcb_ext.c b/src/xcb_ext.c index 3732515..831f283 100644 --- a/src/xcb_ext.c +++ b/src/xcb_ext.c @@ -25,6 +25,10 @@ /* A cache for QueryExtension results. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include @@ -33,18 +37,18 @@ #include "xcbint.h" typedef struct lazyreply { - enum { LAZY_NONE = 0, LAZY_COOKIE, LAZY_FORCED } tag; + enum lazy_reply_tag tag; union { - XCBQueryExtensionCookie cookie; - XCBQueryExtensionRep *reply; + xcb_query_extension_cookie_t cookie; + xcb_query_extension_reply_t *reply; } value; } lazyreply; -static lazyreply *get_index(XCBConnection *c, int index) +static lazyreply *get_index(xcb_connection_t *c, int idx) { - if(index > c->ext.extensions_size) + if(idx > c->ext.extensions_size) { - int new_size = index << 1; + int new_size = idx << 1; lazyreply *new_extensions = realloc(c->ext.extensions, sizeof(lazyreply) * new_size); if(!new_extensions) return 0; @@ -52,10 +56,10 @@ static lazyreply *get_index(XCBConnection *c, int index) c->ext.extensions = new_extensions; c->ext.extensions_size = new_size; } - return c->ext.extensions + index - 1; + return c->ext.extensions + idx - 1; } -static lazyreply *get_lazyreply(XCBConnection *c, XCBExtension *ext) +static lazyreply *get_lazyreply(xcb_connection_t *c, xcb_extension_t *ext) { static pthread_mutex_t global_lock = PTHREAD_MUTEX_INITIALIZER; static int next_global_id; @@ -72,16 +76,16 @@ static lazyreply *get_lazyreply(XCBConnection *c, XCBExtension *ext) { /* cache miss: query the server */ data->tag = LAZY_COOKIE; - data->value.cookie = XCBQueryExtension(c, strlen(ext->name), ext->name); + data->value.cookie = xcb_query_extension(c, strlen(ext->name), ext->name); } return data; } /* Public interface */ -/* Do not free the returned XCBQueryExtensionRep - on return, it's aliased +/* Do not free the returned xcb_query_extension_reply_t - on return, it's aliased * from the cache. */ -const XCBQueryExtensionRep *XCBGetExtensionData(XCBConnection *c, XCBExtension *ext) +const xcb_query_extension_reply_t *xcb_get_extension_data(xcb_connection_t *c, xcb_extension_t *ext) { lazyreply *data; if(c->has_error) @@ -92,14 +96,14 @@ const XCBQueryExtensionRep *XCBGetExtensionData(XCBConnection *c, XCBExtension * if(data && data->tag == LAZY_COOKIE) { data->tag = LAZY_FORCED; - data->value.reply = XCBQueryExtensionReply(c, data->value.cookie, 0); + data->value.reply = xcb_query_extension_reply(c, data->value.cookie, 0); } pthread_mutex_unlock(&c->ext.lock); return data ? data->value.reply : 0; } -void XCBPrefetchExtensionData(XCBConnection *c, XCBExtension *ext) +void xcb_prefetch_extension_data(xcb_connection_t *c, xcb_extension_t *ext) { if(c->has_error) return; @@ -110,14 +114,14 @@ void XCBPrefetchExtensionData(XCBConnection *c, XCBExtension *ext) /* Private interface */ -int _xcb_ext_init(XCBConnection *c) +int _xcb_ext_init(xcb_connection_t *c) { if(pthread_mutex_init(&c->ext.lock, 0)) return 0; return 1; } -void _xcb_ext_destroy(XCBConnection *c) +void _xcb_ext_destroy(xcb_connection_t *c) { pthread_mutex_destroy(&c->ext.lock); while(c->ext.extensions_size-- > 0)