mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-03 04:22:47 -05:00
Make bufchain_prefix return a ptrlen.
Now that all the call sites are expecting a size_t instead of an int length field, it's no longer particularly difficult to make it actually return the pointer,length pair in the form of a ptrlen. It would be nice to say that simplifies call sites because those ptrlens can all be passed straight along to other ptrlen-consuming functions. Actually almost none of the call sites are like that _yet_, but this makes it possible to move them in that direction in future (as part of my general aim to migrate ptrlen-wards as much as I can). But also it's just nicer to keep the pointer and length together in one variable, and not have to declare them both in advance with two extra lines of boilerplate.
This commit is contained in:
@ -329,18 +329,17 @@ size_t try_output(bool is_stderr)
|
||||
{
|
||||
bufchain *chain = (is_stderr ? &stderr_data : &stdout_data);
|
||||
int fd = (is_stderr ? STDERR_FILENO : STDOUT_FILENO);
|
||||
void *senddata;
|
||||
size_t sendlen;
|
||||
ssize_t ret;
|
||||
|
||||
if (bufchain_size(chain) > 0) {
|
||||
bool prev_nonblock = nonblock(fd);
|
||||
ptrlen senddata;
|
||||
do {
|
||||
bufchain_prefix(chain, &senddata, &sendlen);
|
||||
ret = write(fd, senddata, sendlen);
|
||||
senddata = bufchain_prefix(chain);
|
||||
ret = write(fd, senddata.ptr, senddata.len);
|
||||
if (ret > 0)
|
||||
bufchain_consume(chain, ret);
|
||||
} while (ret == sendlen && bufchain_size(chain) != 0);
|
||||
} while (ret == senddata.len && bufchain_size(chain) != 0);
|
||||
if (!prev_nonblock)
|
||||
no_nonblock(fd);
|
||||
if (ret < 0 && errno != EAGAIN) {
|
||||
|
Reference in New Issue
Block a user