From: Thorsten Maerz Date: Thu, 2 Jan 2003 04:21:25 +0000 (+0000) Subject: fixed acessing members of freed pfile struct X-Git-Tag: rel_0_8_9~124 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=9e7299dc5ba4a900533472600a74256f8a45afee fixed acessing members of freed pfile struct --- diff --git a/ChangeLog.claws b/ChangeLog.claws index 88378f7c1..fc5f966fe 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,8 @@ +2003-01-02 [thorsten] 0.8.8claws38 + + * src/prefs.c + fixed acessing members of freed pfile struct + 2003-01-02 [thorsten] 0.8.8claws37 * src/procmsg.c diff --git a/configure.in b/configure.in index a14a4a09d..1a405eca2 100644 --- a/configure.in +++ b/configure.in @@ -11,7 +11,7 @@ MINOR_VERSION=8 MICRO_VERSION=8 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws37 +EXTRA_VERSION=claws38 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl set $target diff --git a/src/common/prefs.c b/src/common/prefs.c index 29483a219..844a38b6e 100644 --- a/src/common/prefs.c +++ b/src/common/prefs.c @@ -28,6 +28,13 @@ #include "prefs.h" #include "utils.h" +/*! + *\brief Open preferences file for reading + * + *\param path Filename with path of preferences file to read + * + *\return PrefFile * preferences file struct + */ PrefFile *prefs_read_open(const gchar *path) { PrefFile *pfile; @@ -50,6 +57,15 @@ PrefFile *prefs_read_open(const gchar *path) return pfile; } +/*! + *\brief Open preferences file for writing + * Prefs are written to a temp file: Call prefs_write_close() + * to rename this to the final filename + * + *\param path Filename with path of preferences file to write + * + *\return PrefFile * preferences file struct + */ PrefFile *prefs_write_open(const gchar *path) { PrefFile *pfile; @@ -84,6 +100,21 @@ PrefFile *prefs_write_open(const gchar *path) return pfile; } +/*! + *\brief Close and free preferences file + * Creates final file from temp, creates backup + * + *\param pfile Preferences file struct + * + *\return 0 on success, -1 on failure + */ +#define PREFS_FILE_FREE() \ +{ \ + if (path) g_free(path); \ + if (tmppath) g_free(tmppath); \ + if (bakpath) g_free(bakpath); \ + if (pfile) g_free(pfile); \ +} gint prefs_file_close(PrefFile *pfile) { FILE *fp, *orig_fp; @@ -97,10 +128,11 @@ gint prefs_file_close(PrefFile *pfile) fp = pfile->fp; orig_fp = pfile->orig_fp; path = pfile->path; - g_free(pfile); if (!pfile->writing) { fclose(fp); + g_free(pfile); + g_free(path); return 0; } @@ -159,12 +191,19 @@ gint prefs_file_close(PrefFile *pfile) return -1; } + g_free(pfile); g_free(path); g_free(tmppath); g_free(bakpath); return 0; } +#undef PREFS_FILE_FREE +/*! + *\brief Close and free preferences file, delete temp file + * + *\param pfile Preferences file struct + */ gint prefs_file_close_revert(PrefFile *pfile) { gchar *tmppath; @@ -186,6 +225,9 @@ gint prefs_file_close_revert(PrefFile *pfile) return 0; } +/*! + *\brief Check if "path" is a file and readonly + */ gboolean prefs_is_readonly(const gchar * path) { if (path == NULL) @@ -194,6 +236,9 @@ gboolean prefs_is_readonly(const gchar * path) return (access(path, W_OK) != 0 && access(path, F_OK) == 0); } +/*! + *\brief Check if "rcfile" is in rcdir, a file and readonly + */ gboolean prefs_rc_is_readonly(const gchar * rcfile) { gboolean result; @@ -209,6 +254,14 @@ gboolean prefs_rc_is_readonly(const gchar * rcfile) return result; } +/*! + *\brief Selects current section in preferences file + * Creates section if file is written + * + *\param pfile Preferences file struct + * + *\return 0 on success, -1 on failure + */ gint prefs_set_block_label(PrefFile *pfile, const gchar *label) { gchar *block_label;