about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-11-08 15:07:13 -0500
committerJune McEnroe <june@causal.agency>2020-11-08 15:07:13 -0500
commita8264f31e02b9ec064e6b3d959c50b854861f0fb (patch)
tree9f46b736383c3bde8dd9809f0925c99f3face22d
parentHighlight changed portion of topic (diff)
downloadcatgirl-a8264f31e02b9ec064e6b3d959c50b854861f0fb.tar.gz
catgirl-a8264f31e02b9ec064e6b3d959c50b854861f0fb.zip
Remove static buffer from capList
-rw-r--r--handle.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/handle.c b/handle.c
index 58510a2..28824d4 100644
--- a/handle.c
+++ b/handle.c
@@ -63,16 +63,13 @@ static enum Cap capParse(const char *list) {
 	return caps;
 }
 
-static const char *capList(enum Cap caps) {
-	static char buf[1024];
-	buf[0] = '\0';
-	struct Cat cat = { buf, sizeof(buf), 0 };
+static const char *capList(struct Cat *cat, enum Cap caps) {
 	for (size_t i = 0; i < ARRAY_LEN(CapNames); ++i) {
 		if (caps & (1 << i)) {
-			catf(&cat, "%s%s", (buf[0] ? " " : ""), CapNames[i]);
+			catf(cat, "%s%s", (cat->len ? " " : ""), CapNames[i]);
 		}
 	}
-	return buf;
+	return cat->buf;
 }
 
 static void require(struct Message *msg, bool origin, uint len) {
@@ -143,7 +140,9 @@ static void handleCap(struct Message *msg) {
 			caps &= ~CapConsumer;
 		}
 		if (caps) {
-			ircFormat("CAP REQ :%s\r\n", capList(caps));
+			char buf[512] = "";
+			struct Cat cat = { buf, sizeof(buf), 0 };
+			ircFormat("CAP REQ :%s\r\n", capList(&cat, caps));
 		} else {
 			if (!(self.caps & CapSASL)) ircFormat("CAP END\r\n");
 		}