From: Radoslaw Jablonski <ext-jablonski.radoslaw@nokia.com>
To: linux-bluetooth@vger.kernel.org
Cc: Radoslaw Jablonski <ext-jablonski.radoslaw@nokia.com>
Subject: [PATCH 2/3] Move freeing contacts data to phonebook_req_finalize
Date: Wed, 2 Feb 2011 10:15:30 +0200 [thread overview]
Message-ID: <1296634531-32164-2-git-send-email-ext-jablonski.radoslaw@nokia.com> (raw)
In-Reply-To: <1296634531-32164-1-git-send-email-ext-jablonski.radoslaw@nokia.com>
Previously data used for generating vcards was freed only in
gen_vcards body. This may result a memory leak, if fetching data
from tracker was cancelled in the middle of process and gen_vcards
wasn't called. Phonebook_req_finalize is better place for this
kind of cleanup.
---
plugins/phonebook-tracker.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index e60cf74..3b61d6b 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -1326,10 +1326,6 @@ static GString *gen_vcards(GSList *contacts,
struct contact_data *c_data = l->data;
phonebook_add_contact(vcards, c_data->contact,
params->filter, params->format);
-
- g_free(c_data->id);
- phonebook_contact_free(c_data->contact);
- g_free(c_data);
}
return vcards;
@@ -1789,6 +1785,7 @@ done:
void phonebook_req_finalize(void *request)
{
struct phonebook_data *data = request;
+ GSList *l;
DBG("");
@@ -1800,6 +1797,15 @@ void phonebook_req_finalize(void *request)
dbus_pending_call_unref(data->call);
+ /* freeing list of contacts used for generating vcards */
+ for (l = data->contacts; l; l = l->next) {
+ struct contact_data *c_data = l->data;
+
+ g_free(c_data->id);
+ phonebook_contact_free(c_data->contact);
+ g_free(c_data);
+ }
+
g_slist_free(data->contacts);
g_free(data);
}
--
1.7.0.4
next prev parent reply other threads:[~2011-02-02 8:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-02 8:15 [PATCH 1/3] Add libtracker-sparql to obexd dependencies Radoslaw Jablonski
2011-02-02 8:15 ` Radoslaw Jablonski [this message]
2011-02-02 8:15 ` [PATCH 3/3] Use libtracker-sparql in PBAP Radoslaw Jablonski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1296634531-32164-2-git-send-email-ext-jablonski.radoslaw@nokia.com \
--to=ext-jablonski.radoslaw@nokia.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox