# HG changeset patch # User Eric Warmenhoven # Date 1004870799 0 # Node ID f6f2871d77c223d42855ffacf2c0b661e7ae148b # Parent 44773c4b0f166ff47ed33e728018ae7994f116d3 [gaim-migrate @ 2683] "just come a little closer" committer: Tailor Script diff -r 44773c4b0f16 -r f6f2871d77c2 plugins/lagmeter.c --- a/plugins/lagmeter.c Sun Nov 04 07:42:28 2001 +0000 +++ b/plugins/lagmeter.c Sun Nov 04 10:46:39 2001 +0000 @@ -79,6 +79,7 @@ ms += tv.tv_usec - my_lag_tv.tv_usec; update_lag(ms); + g_free(*message); *message = NULL; } g_free(name); diff -r 44773c4b0f16 -r f6f2871d77c2 src/gtkspell.c --- a/src/gtkspell.c Sun Nov 04 07:42:28 2001 +0000 +++ b/src/gtkspell.c Sun Nov 04 10:46:39 2001 +0000 @@ -76,26 +76,44 @@ } static char *readline() { - int len = 1024; - gchar *buf = g_malloc(len); - int pos = 0; - do { - int val = read(fd_read[0], buf + pos, 1); - if (val <= 0) { + static gchar *buf = NULL; + char *end; + char *ret; + char *tmp; + + /* read until we get a newline */ + while (!buf || (end = strchr(buf, '\n')) == NULL) { + char space[1024]; + int ret = read(fd_read[0], space, 1023); + if (ret < 0) { error_print("read: %s\n", strerror(errno)); - g_free(buf); return NULL; } - pos += val; - if (pos == len) { - len *= 2; - buf = g_realloc(buf, len); - } - } while (buf[pos - 1] != '\n'); + space[ret] = 0; + if (buf) { + tmp = buf; + buf = g_strconcat(tmp, space, NULL); + g_free(tmp); + } else + buf = g_strdup(space); + } + + /* we got a newline, and end points to it. + * copy out the data, reset buf, return */ - buf = g_realloc(buf, pos + 1); - buf[pos] = 0; - return buf; + if (end[1] == 0) { + /* only one line is in the buffer */ + ret = buf; + buf = NULL; + return ret; + } + + ret = g_strndup(buf, end - buf + 1); + tmp = buf; + buf = g_strdup(end + 1); + g_free(tmp); + + return ret; } static char *readresponse() {