Move _xcb_readn to xcb_in.c and make it static. Minor change to _xcb_read_block to...
authorJamey Sharp <jamey@minilop.net>
Fri, 24 Feb 2006 08:48:18 +0000 (00:48 -0800)
committerJamey Sharp <jamey@minilop.net>
Fri, 24 Feb 2006 08:48:18 +0000 (00:48 -0800)
src/xcb_in.c
src/xcb_util.c
src/xcbint.h

index 967beac..4a62a48 100644 (file)
@@ -28,6 +28,7 @@
 #include <assert.h>
 #include <string.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <stdio.h>
 #include <errno.h>
 
@@ -68,6 +69,14 @@ static void wake_up_next_reader(XCBConnection *c)
     assert(pthreadret == 0);
 }
 
+static int readn(const int fd, void *buf, const int buflen, int *count)
+{
+    int n = read(fd, ((char *) buf) + *count, buflen - *count);
+    if(n > 0)
+        *count += n;
+    return n;
+}
+
 static int read_packet(XCBConnection *c)
 {
     XCBGenericRep genrep;
@@ -327,7 +336,7 @@ int _xcb_in_expect_reply(XCBConnection *c, unsigned int request, enum workaround
 
 int _xcb_in_read(XCBConnection *c)
 {
-    int n = _xcb_readn(c->fd, c->in.queue, sizeof(c->in.queue), &c->in.queue_len);
+    int n = readn(c->fd, c->in.queue, sizeof(c->in.queue), &c->in.queue_len);
     while(read_packet(c))
         /* empty */;
     return (n > 0) || (n < 0 && errno == EAGAIN);
index db3bffb..c9c7f92 100644 (file)
@@ -217,20 +217,14 @@ int _xcb_set_fd_flags(const int fd)
     return 1;
 }
 
-int _xcb_readn(const int fd, void *buf, const int buflen, int *count)
-{
-    int n = read(fd, ((char *) buf) + *count, buflen - *count);
-    if(n > 0)
-        *count += n;
-    return n;
-}
-
 int _xcb_read_block(const int fd, void *buf, const size_t len)
 {
     int done = 0;
     while(done < len)
     {
-        int ret = _xcb_readn(fd, buf, len, &done);
+        int ret = read(fd, ((char *) buf) + done, len - done);
+        if(ret > 0)
+            done += ret;
         if(ret < 0 && errno == EAGAIN)
         {
             fd_set fds;
index e7e6688..ebbb2fe 100644 (file)
@@ -72,7 +72,6 @@ void *_xcb_map_remove(_xcb_map *q, unsigned int key);
 #define XCB_PAD(i) ((4 - (i & 3)) & 3)
 
 int _xcb_set_fd_flags(const int fd);
-int _xcb_readn(const int fd, void *buf, const int buflen, int *count);
 int _xcb_read_block(const int fd, void *buf, const size_t len);