Mercurial > pidgin
changeset 7764:88886239f31e
[gaim-migrate @ 8409]
Move old_logger to stringrefs for paths
committer: Tailor Script <tailor@pidgin.im>
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Fri, 05 Dec 2003 16:57:00 +0000 |
parents | dc79649b829d |
children | 9b3c8ef31105 |
files | src/log.c |
diffstat | 1 files changed, 12 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/log.c Fri Dec 05 16:56:03 2003 +0000 +++ b/src/log.c Fri Dec 05 16:57:00 2003 +0000 @@ -27,6 +27,7 @@ #include "log.h" #include "prefs.h" #include "util.h" +#include "stringref.h" static GaimLogLogger html_logger; static GaimLogLogger txt_logger; @@ -696,7 +697,7 @@ */ struct old_logger_data { - char *path; + GaimStringref *pathref; int offset; int length; }; @@ -709,7 +710,8 @@ char month[4]; struct old_logger_data *data = NULL; char *logfile = g_strdup_printf("%s.log", gaim_normalize(account, sn)); - char *path = g_build_filename(gaim_user_dir(), "logs", logfile, NULL); + char *pathstr = g_build_filename(gaim_user_dir(), "logs", logfile, NULL); + GaimStringref *pathref = gaim_stringref_new(pathstr); char *newlog; int logfound = 0; int lastoff = 0; @@ -720,9 +722,10 @@ GList *list = NULL; g_free(logfile); + g_free(pathstr); - if (!(file = fopen(path, "rb"))) { - g_free(path); + if (!(file = fopen(gaim_stringref_value(pathref), "rb"))) { + gaim_stringref_unref(pathref); return NULL; } @@ -763,7 +766,7 @@ data = g_new0(struct old_logger_data, 1); data->offset = lastoff; data->length = newlen; - data->path = g_strdup(path); + data->pathref = gaim_stringref_ref(pathref); log->logger_data = data; list = g_list_append(list, log); } @@ -814,13 +817,13 @@ data = g_new0(struct old_logger_data, 1); data->offset = lastoff; data->length = newlen; - data->path = g_strdup(path); + data->pathref = gaim_stringref_ref(pathref); log->logger_data = data; list = g_list_append(list, log); } } - g_free(path); + gaim_stringref_unref(pathref); fclose(file); return list; } @@ -828,7 +831,7 @@ static char * old_logger_read (GaimLog *log, GaimLogReadFlags *flags) { struct old_logger_data *data = log->logger_data; - FILE *file = fopen(data->path, "rb"); + FILE *file = fopen(gaim_stringref_value(data->pathref), "rb"); char *read = g_malloc(data->length + 1); fseek(file, data->offset, SEEK_SET); fread(read, data->length, 1, file); @@ -848,7 +851,7 @@ static void old_logger_finalize(GaimLog *log) { struct old_logger_data *data = log->logger_data; - g_free(data->path); + gaim_stringref_unref(data->pathref); g_free(data); }