# HG changeset patch # User Ethan Blanton # Date 1070640513 0 # Node ID 946120d41b7736cd78b8daf77de2ec1e59dd8dfa # Parent 7c4fbd9f1aede8703938991a7dba178c8e185a53 [gaim-migrate @ 8406] This doesn't solve the slowdown, but if nothing else 150,000 allocations are better than 177,000, right? committer: Tailor Script diff -r 7c4fbd9f1aed -r 946120d41b77 src/log.c --- a/src/log.c Fri Dec 05 12:56:59 2003 +0000 +++ b/src/log.c Fri Dec 05 16:08:33 2003 +0000 @@ -706,11 +706,15 @@ FILE *file; char buf[BUF_LONG]; struct tm tm; + char month[4]; struct old_logger_data *data = NULL; - char month[4]; char *logfile = g_strdup_printf("%s.log", gaim_normalize(account, sn)); char *path = g_build_filename(gaim_user_dir(), "logs", logfile, NULL); char *newlog; + int logfound = 0; + int lastoff = 0; + int newlen; + time_t lasttime; GaimLog *log = NULL; GList *list = NULL; @@ -738,34 +742,35 @@ offset = ftell(file); - if (data) { - data->length = offset - data->offset - length; + if (logfound) { + newlen = offset - lastoff - length; if(strstr(buf, "----
")) { - data->length -= - strlen("

---- New Conversation @ ") + - strlen("----


"); + newlen -= + sizeof("

---- New Conversation @ ") + + sizeof("----


") - 2; } else { - data->length -= - strlen("---- New Conversation @ ") + strlen("----"); + newlen -= + sizeof("---- New Conversation @ ") + sizeof("----") - 2; } if(strchr(buf, '\r')) data->length--; - if (data->length != 0) + if (newlen != 0) { + log = gaim_log_new(GAIM_LOG_IM, sn, account, -1); + log->logger = &old_logger; + log->time = lasttime; + data = g_new0(struct old_logger_data, 1); + data->offset = lastoff; + data->length = newlen; + data->path = g_strdup(path); + log->logger_data = data; list = g_list_append(list, log); - else - gaim_log_free(log); + } } - log = gaim_log_new(GAIM_LOG_IM, sn, account, -1); - log->logger = &old_logger; - - data = g_new0(struct old_logger_data, 1); - data->offset = offset; - data->path = g_strdup(path); - log->logger_data = data; - + logfound = 1; + lastoff = offset; g_snprintf(convostart, length, "%s", temp); sscanf(convostart, "%*s %s %d %d:%d:%d %d", @@ -797,16 +802,22 @@ tm.tm_mon = 11; } tm.tm_year -= 1900; - log->time = mktime(&tm); + lasttime = mktime(&tm); } } - if (data) { - data->length = ftell(file) - data->offset; - if (data->length != 0) + if (logfound) { + if ((newlen = ftell(file) - lastoff) != 0) { + log = gaim_log_new(GAIM_LOG_IM, sn, account, -1); + log->logger = &old_logger; + log->time = lasttime; + data = g_new0(struct old_logger_data, 1); + data->offset = lastoff; + data->length = newlen; + data->path = g_strdup(path); + log->logger_data = data; list = g_list_append(list, log); - else - gaim_log_free(log); + } } g_free(path);