From 3931e7bee90d9f37c1f01f60b6242b6ed29b00d0 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 26 May 2014 18:54:56 +1000 Subject: [PATCH] Avoid realloc being required in send_json_msg --- src/generator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/generator.c b/src/generator.c index 245bbab7..7264a956 100644 --- a/src/generator.c +++ b/src/generator.c @@ -269,10 +269,10 @@ static bool send_json_msg(connsock_t *cs, json_t *json_msg) s = json_dumps(json_msg, JSON_ESCAPE_SLASH); LOGDEBUG("Sending json msg: %s", s); - realloc_strcat(&s, "\n"); - len = strlen(s); + len = strlen(s) + 1; sent = write_socket(cs->fd, s, len); dealloc(s); + sent += write_socket(cs->fd, "\n", 1); if (sent != len) { LOGWARNING("Failed to send %d bytes in send_json_msg", len); return false;