summary refs log tree commit diff
path: root/bounce.c
diff options
context:
space:
mode:
Diffstat (limited to 'bounce.c')
-rw-r--r--bounce.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/bounce.c b/bounce.c
index 3e30d0c..e91ed7f 100644
--- a/bounce.c
+++ b/bounce.c
@@ -35,7 +35,7 @@ static struct {
 
 static void loopAdd(int fd, struct Client *client) {
 	if (loop.len == loop.cap) {
-		loop.cap *= 2;
+		loop.cap = (loop.cap ? loop.cap * 2 : 4);
 		loop.fds = realloc(loop.fds, sizeof(struct pollfd) * loop.cap);
 		loop.clients = realloc(loop.clients, sizeof(struct Client *) * loop.cap);
 		if (!loop.fds || !loop.clients) err(EX_OSERR, "realloc");
@@ -48,9 +48,9 @@ static void loopAdd(int fd, struct Client *client) {
 }
 
 static void loopRemove(size_t i) {
-	loop.fds[i] = loop.fds[loop.len - 1];
-	loop.clients[i] = loop.clients[loop.len - 1];
 	loop.len--;
+	loop.fds[i] = loop.fds[loop.len];
+	loop.clients[i] = loop.clients[loop.len];
 }
 
 static char *censor(char *arg) {
9-07-13 15:34:20 -0400'>2019-07-13Add shotty -cJune McEnroe 2019-07-13Add DL to shottyJune McEnroe 2019-07-12Color html rather than bodyJune McEnroe If background-color is only set on body then overscroll in Safari reveals white. 2019-07-12Make author consistent and update URLsJune McEnroe 2019-07-12Move to www/text.causal.agencyJune McEnroe 2019-07-12Add new causal.agency with shotty shotsJune McEnroe 2019-07-12Use -s to infer terminal sizeJune McEnroe 2019-07-12Add DCH to shottyJune McEnroe This makes htop mostly work. Scrolling region still missing. 2019-07-12Support insert mode in shottyJune McEnroe This is how curses puts characters into the bottom-right cell of the terminal. 2019-07-11Don't do carriage return on line feedJune McEnroe 2019-07-11Interpret 256color-style SGRsJune McEnroe 2019-07-11Use inline style rather than <b>, <i>, <u>June McEnroe 2019-07-11Factor out clearJune McEnroe 2019-07-11Add bright option to shottyJune McEnroe 2019-07-11Output <b>, <i>, <u> in shottyJune McEnroe 2019-07-10Ignore SM and RMJune McEnroe 2019-07-09Add shotty man page and build itJune McEnroe 2019-07-09Add up -cJune McEnroe 2019-07-09Add options for default colors to shottyJune McEnroe 2019-07-08Use char literals consistentlyJune McEnroen title='2017-03-14 22:36:07 -0400'>2017-03-14Add bri brightness control scriptJune McEnroe This is probably terrible. 2017-03-14Add comment to tmux terminal overrideJune McEnroe 2017-03-13Have tmux set block cursor on linux consoleJune McEnroe 2017-03-13Use inverse for Visual in colorschemeJune McEnroe