From: Axel Wagner Date: Fri, 17 Sep 2010 00:28:56 +0000 (+0200) Subject: Use realloc instead of manually reallocating X-Git-Tag: 4.0.1~7^2~63 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d245d14765ef0676c85a346e3bea9cf25fe44a32;p=i3%2Fi3 Use realloc instead of manually reallocating --- diff --git a/i3bar/src/child.c b/i3bar/src/child.c index 97162cb4..a4c33bcd 100644 --- a/i3bar/src/child.c +++ b/i3bar/src/child.c @@ -61,12 +61,8 @@ void stdin_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) { } if (n == 0) { if (rec == buffer_len) { - char *tmp = buffer; - buffer = malloc(buffer_len + STDIN_CHUNK_SIZE); - memset(buffer, '\0', buffer_len); - strncpy(buffer, tmp, buffer_len); buffer_len += STDIN_CHUNK_SIZE; - FREE(tmp); + buffer = realloc(buffer, buffer_len); } else { /* remove trailing newline and finish up */ buffer[rec-1] = '\0';