summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-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) {
pan>Print octal for 8 bits in bitJune McEnroe 2020-12-30Add unary & to bitJune McEnroe Also unary + and fix precedence of unary -. 2020-12-30Support unary + in orderJune McEnroe Missed this because operator(7) just doesn't list it, oddly. 2020-12-30Add postfix $ operator to bitJune McEnroe 2020-12-29Add make lexerJune McEnroe This is kind of a mess and needs to be cleaned up against more careful reading of the make grammar. 2020-12-29Clean up C lexerJune McEnroe This ordering of rules feels much cleaner. 2020-12-29Clean up hilex code somewhatJune McEnroe 2020-12-29Match lex/yacc %% %{ %} lines as MacroJune McEnroe 2020-12-29Match top-level C definitions as IdentifierTagJune McEnroe 2020-12-29Match C type declarations as IdentifierTagJune McEnroe 2020-12-29Match function-like macro definitions as IdentifierTagJune McEnroe 2020-12-29Reconfigure C macro start conditionsJune McEnroe 2020-12-29Document HTML class namesJune McEnroe 2020-12-29Rename Tag class to IdentifierTagJune McEnroe 2020-12-29Change HTML class from hi to hilexJune McEnroe You can tell I was just copying the HTML code huh. 2020-12-29Add hilex HTML outputJune McEnroe