summary refs log tree commit diff
path: root/bounce.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-10-23 03:12:45 -0400
committerJune McEnroe <june@causal.agency>2019-10-23 03:12:45 -0400
commitf4ba2638c774e0dedf4cf2e965218b3600c1e1ba (patch)
tree16991c4f3bd8e8924ee9adc1cc5591f6ca4ccc4d /bounce.c
parentFix rest parsing (diff)
downloadpounce-f4ba2638c774e0dedf4cf2e965218b3600c1e1ba.tar.gz
pounce-f4ba2638c774e0dedf4cf2e965218b3600c1e1ba.zip
Set an initial loop cap
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) {
&follow=1'>Add before and after optionsJune McEnroe 2019-12-31Add scoop IRC output formatJune McEnroe 2019-12-31Add scoop output format optionJune McEnroe 2019-12-31Refactor scoop formatters and group colored outputJune McEnroe 2019-12-31Add strftime format string optionJune McEnroe 2019-12-31Refactor binding in scoopJune McEnroe 2019-12-31Add option to group events by contextJune McEnroe 2019-12-31Add missing includeJune McEnroe 2019-12-31Use standout mode for highlightingJune McEnroe 2019-12-31Rewrite scoop(1) argument descriptionsJune McEnroe 2019-12-31Color both nicks in a changeJune McEnroe 2019-12-31Implement nick-colored outputJune McEnroe 2019-12-31Only enable highlighting on terminal outputJune McEnroe 2019-12-31Set up pager pipeJune McEnroe 2019-12-30Normalize date inputJune McEnroe 2019-12-30Add initial rough version of scoopJune McEnroe 2019-12-30Join with USING wherever possibleJune McEnroe 2019-12-30Add -D flag to prospective scoop manualJune McEnroe 2019-12-30Order results by ID in outer query in litterboxJune McEnroe 2019-12-30Use X macro for Type enumJune McEnroe 2019-12-30Remove scoop -ABCJune McEnroe 2019-12-30Add limit option for litterbox's search query interfaceJune McEnroe