From 9cdee141ad068801a54b004dd4e17cd325b64eae Mon Sep 17 00:00:00 2001 From: Not Zed Date: Thu, 9 Jan 2003 06:43:31 +0000 Subject: g_free->xmlFree (account_to_xml): copy xml memory to glib memory when 2003-01-09 Not Zed * mail-config.c (xml_get_prop): g_free->xmlFree (account_to_xml): copy xml memory to glib memory when adding the 0 on the end of the string. (accounts_save): Use slightly different logic with appending to the tail of the list, we can't use the &node trick with gslists. (accounts_changed): Same here. svn path=/trunk/; revision=19306 --- mail/mail-config.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'mail/mail-config.c') diff --git a/mail/mail-config.c b/mail/mail-config.c index 78bea6fd29..2e8edde06f 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -300,7 +300,7 @@ xml_get_prop (xmlNodePtr node, const char *name) buf = xmlGetProp (node, name); val = g_strdup (buf); - g_free (buf); + xmlFree (buf); return val; } @@ -532,15 +532,14 @@ account_to_xml (MailConfigAccount *account) xmlDocDumpMemory (doc, &xmlbuf, &n); xmlFreeDoc (doc); - - if (!(tmp = realloc (xmlbuf, n + 1))) { - g_free (xmlbuf); - return NULL; - } - - xmlbuf[n] = '\0'; - - return xmlbuf; + + /* remap to glib memory */ + tmp = g_malloc(n+1); + memcpy(tmp, xmlbuf, n); + tmp[n] = 0; + xmlFree(xmlbuf); + + return tmp; } static void @@ -560,8 +559,7 @@ accounts_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointe config->accounts = NULL; } - tail = (GSList *) &config->accounts; - + tail = NULL; list = gconf_client_get_list (config->gconf, "/apps/evolution/mail/accounts", GCONF_VALUE_STRING, NULL); @@ -574,7 +572,10 @@ accounts_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointe n->data = account; n->next = NULL; - tail->next = n; + if (tail == NULL) + config->accounts = n; + else + tail->next = n; tail = n; } @@ -591,7 +592,7 @@ accounts_save (void) char *xmlbuf; list = NULL; - tail = (GSList *) &list; + tail = NULL; l = config->accounts; while (l != NULL) { @@ -599,8 +600,11 @@ accounts_save (void) n = g_slist_alloc (); n->data = xmlbuf; n->next = NULL; - - tail->next = n; + + if (tail == NULL) + list = n; + else + tail->next = n; tail = n; } -- cgit v1.2.3