mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-12 08:43:53 -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:
@ -164,8 +164,6 @@ static void sk_handle_flush(Socket *s)
|
||||
static void handle_socket_unfreeze(void *hsv)
|
||||
{
|
||||
HandleSocket *hs = (HandleSocket *)hsv;
|
||||
void *data;
|
||||
size_t len;
|
||||
|
||||
/*
|
||||
* If we've been put into a state other than THAWING since the
|
||||
@ -177,16 +175,16 @@ static void handle_socket_unfreeze(void *hsv)
|
||||
/*
|
||||
* Get some of the data we've buffered.
|
||||
*/
|
||||
bufchain_prefix(&hs->inputdata, &data, &len);
|
||||
assert(len > 0);
|
||||
ptrlen data = bufchain_prefix(&hs->inputdata);
|
||||
assert(data.len > 0);
|
||||
|
||||
/*
|
||||
* Hand it off to the plug. Be careful of re-entrance - that might
|
||||
* have the effect of trying to close this socket.
|
||||
*/
|
||||
hs->defer_close = true;
|
||||
plug_receive(hs->plug, 0, data, len);
|
||||
bufchain_consume(&hs->inputdata, len);
|
||||
plug_receive(hs->plug, 0, data.ptr, data.len);
|
||||
bufchain_consume(&hs->inputdata, data.len);
|
||||
hs->defer_close = false;
|
||||
if (hs->deferred_close) {
|
||||
sk_handle_close(&hs->sock);
|
||||
|
Reference in New Issue
Block a user