From d245d14765ef0676c85a346e3bea9cf25fe44a32 Mon Sep 17 00:00:00 2001 From: Axel Wagner Date: Fri, 17 Sep 2010 02:28:56 +0200 Subject: [PATCH] Use realloc instead of manually reallocating --- i3bar/src/child.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) 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'; -- 2.39.5