Move _xcb_write and _xcb_writev to xcb_out.c and make them static, since only _xcb_out_write calls them.
This commit is contained in:
parent
213b572592
commit
55c1842686
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
@ -47,6 +48,40 @@ static int force_sequence_wrap(XCBConnection *c)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _xcb_write(const int fd, char (*buf)[], int *count)
|
||||||
|
{
|
||||||
|
int n = write(fd, *buf, *count);
|
||||||
|
if(n > 0)
|
||||||
|
{
|
||||||
|
*count -= n;
|
||||||
|
if(*count)
|
||||||
|
memmove(*buf, *buf + n, *count);
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _xcb_writev(const int fd, struct iovec *vec, int count)
|
||||||
|
{
|
||||||
|
int n = writev(fd, vec, count);
|
||||||
|
if(n > 0)
|
||||||
|
{
|
||||||
|
int rem = n;
|
||||||
|
for(; count; --count, ++vec)
|
||||||
|
{
|
||||||
|
int cur = vec->iov_len;
|
||||||
|
if(cur > rem)
|
||||||
|
cur = rem;
|
||||||
|
vec->iov_len -= cur;
|
||||||
|
vec->iov_base = (char *) vec->iov_base + cur;
|
||||||
|
rem -= cur;
|
||||||
|
if(vec->iov_len)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
assert(rem == 0);
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
/* Public interface */
|
/* Public interface */
|
||||||
|
|
||||||
CARD32 XCBGetMaximumRequestLength(XCBConnection *c)
|
CARD32 XCBGetMaximumRequestLength(XCBConnection *c)
|
||||||
|
|
|
@ -243,37 +243,3 @@ int _xcb_read_block(const int fd, void *buf, const size_t len)
|
||||||
}
|
}
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _xcb_write(const int fd, char (*buf)[], int *count)
|
|
||||||
{
|
|
||||||
int n = write(fd, *buf, *count);
|
|
||||||
if(n > 0)
|
|
||||||
{
|
|
||||||
*count -= n;
|
|
||||||
if(*count)
|
|
||||||
memmove(*buf, *buf + n, *count);
|
|
||||||
}
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
int _xcb_writev(const int fd, struct iovec *vec, int count)
|
|
||||||
{
|
|
||||||
int n = writev(fd, vec, count);
|
|
||||||
if(n > 0)
|
|
||||||
{
|
|
||||||
int rem = n;
|
|
||||||
for(; count; --count, ++vec)
|
|
||||||
{
|
|
||||||
int cur = vec->iov_len;
|
|
||||||
if(cur > rem)
|
|
||||||
cur = rem;
|
|
||||||
vec->iov_len -= cur;
|
|
||||||
vec->iov_base = (char *) vec->iov_base + cur;
|
|
||||||
rem -= cur;
|
|
||||||
if(vec->iov_len)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
assert(rem == 0);
|
|
||||||
}
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
|
@ -84,8 +84,6 @@ void *_xcb_map_remove(_xcb_map *q, unsigned int key);
|
||||||
int _xcb_set_fd_flags(const int fd);
|
int _xcb_set_fd_flags(const int fd);
|
||||||
int _xcb_readn(const int fd, void *buf, const int buflen, int *count);
|
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);
|
int _xcb_read_block(const int fd, void *buf, const size_t len);
|
||||||
int _xcb_write(const int fd, char (*buf)[], int *count);
|
|
||||||
int _xcb_writev(const int fd, struct iovec *vec, int count);
|
|
||||||
|
|
||||||
|
|
||||||
/* xcb_out.c */
|
/* xcb_out.c */
|
||||||
|
|
Loading…
Reference in New Issue