irctk

libircclient binding for scripts
git clone https://a3nm.net/git/irctk/
Log | Files | Refs | README

commit ffa34f84924c7820c56f156c12e7b8087b913f3c
parent 77a0d177719894d9baedce11c29ef0e18d0fd498
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Mon, 25 Jun 2012 18:10:19 +0200

no reuse with getline, and use size_t

Diffstat:
irctk.c | 10++++------
1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/irctk.c b/irctk.c @@ -1288,11 +1288,10 @@ static void* irc_thread (void *arg) // The fifo_in thread entry point static void* fifo_in_thread (void *arg) { char *line = NULL; - int res, size=100; - line = malloc(size+1); - assert(line); + int res; + size_t size; - while ((res = getline((char**) &line, (size_t*) &size, stdin)) != -1) { + while ((res = getline(&line, (size_t*) &size, stdin)) != -1) { debug("[thread_in] READS %s", line); debug("someone will have to free %p", line); if (line[0] == '[' && args.destination_prefix) @@ -1322,8 +1321,7 @@ static void* fifo_in_thread (void *arg) { } // reallocate line, the popper will free the line - line = malloc(size+1); - assert(line); + line = NULL; } // sentinel debug("[thread_in] pushed sentinel");