1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-25 09:12:24 +00:00

Correct code to insert into a doubly-linked list.

[originally from svn r2553]
This commit is contained in:
Ben Harris 2003-01-12 13:50:04 +00:00
parent 1b5cb7adf6
commit 05ae857752
3 changed files with 14 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $Id: macterm.c,v 1.40 2003/01/12 01:25:34 ben Exp $ */ /* $Id: macterm.c,v 1.41 2003/01/12 13:50:04 ben Exp $ */
/* /*
* Copyright (c) 1999 Simon Tatham * Copyright (c) 1999 Simon Tatham
* Copyright (c) 1999, 2002 Ben Harris * Copyright (c) 1999, 2002 Ben Harris
@ -188,6 +188,7 @@ void mac_startsession(Session *s)
ShowWindow(s->window); ShowWindow(s->window);
s->next = sesslist; s->next = sesslist;
s->prev = s->next->prev; s->prev = s->next->prev;
if (ret->next != NULL)
s->next->prev = &s->next; s->next->prev = &s->next;
sesslist = s; sesslist = s;
} }

View File

@ -504,6 +504,7 @@ Socket mactcp_new(SockAddr addr, int port, int privport, int oobinline,
/* Add this to the list of all sockets */ /* Add this to the list of all sockets */
ret->next = mactcp.socklist; ret->next = mactcp.socklist;
ret->prev = &mactcp.socklist; ret->prev = &mactcp.socklist;
if (ret->next != NULL)
ret->next->prev = &ret->next; ret->next->prev = &ret->next;
mactcp.socklist = ret; mactcp.socklist = ret;

View File

@ -313,6 +313,8 @@ Socket ot_new(SockAddr addr, int port, int privport, int oobinline,
/* Add this to the list of all sockets */ /* Add this to the list of all sockets */
ret->next = ot.socklist; ret->next = ot.socklist;
ret->prev = &ot.socklist; ret->prev = &ot.socklist;
if (ret->next != NULL)
ret->next->prev = &ret->next;
ot.socklist = ret; ot.socklist = ret;
return (Socket) ret; return (Socket) ret;
@ -462,9 +464,13 @@ void ot_recv(Actual_Socket s)
if (s->frozen) return; if (s->frozen) return;
while ((o = OTRcv(s->ep, buf, sizeof(buf), &flags)) != kOTNoDataErr) { do {
o = OTRcv(s->ep, buf, sizeof(buf), &flags);
if (o > 0)
plug_receive(s->plug, 0, buf, sizeof(buf)); plug_receive(s->plug, 0, buf, sizeof(buf));
} if (o < 0 && o != kOTNoDataErr)
plug_closing(s->plug, NULL, 0, 0); /* XXX Error msg */
} while (o > 0);
} }