Bug 556910 – [fam-helper.c:223]: Memory leak: sub

2008-10-24  Matthias Clasen  <mclasen@redhat.com>

        Bug 556910 – [fam-helper.c:223]: Memory leak: sub

        * fam/fam-helper.c: Fix a memory leak and formatting issues.
        Reported by Daniel Marjamäki


svn path=/trunk/; revision=7624
This commit is contained in:
Matthias Clasen 2008-10-24 04:04:42 +00:00 committed by Matthias Clasen
parent 05fb3a25e5
commit b616e892ca
2 changed files with 115 additions and 98 deletions

View File

@ -1,3 +1,10 @@
2008-10-24 Matthias Clasen <mclasen@redhat.com>
Bug 556910 [fam-helper.c:223]: Memory leak: sub
* fam/fam-helper.c: Fix a memory leak and formatting issues.
Reported by Daniel Marjamäki
2008-10-23 Matthias Clasen <mclasen@redhat.com>
* gdesktopappinfo.c (g_app_info_reset_type_associations): Fix docs.

View File

@ -70,12 +70,14 @@ fam_event_to_file_monitor_event (int code)
static gboolean
fam_do_iter_unlocked (void)
{
while (fam_connection != NULL && FAMPending (fam_connection)) {
while (fam_connection != NULL && FAMPending (fam_connection))
{
FAMEvent ev;
fam_sub* sub = NULL;
gboolean cancelled;
if (FAMNextEvent (fam_connection, &ev) != 1) {
if (FAMNextEvent (fam_connection, &ev) != 1)
{
FAMClose (fam_connection);
g_free (fam_connection);
g_source_remove (fam_watch_id);
@ -117,7 +119,9 @@ fam_do_iter_unlocked (void)
g_free (path);
g_object_unref (child);
g_object_unref (parent);
} else {
}
else
{
GFile *child;
GFileMonitor* monitor = G_FILE_MONITOR (sub->user_data);
GFileMonitorEvent eflags = fam_event_to_file_monitor_event (ev.code);
@ -157,9 +161,11 @@ _fam_sub_startup (void)
G_LOCK (fam_connection);
if (fam_connection == NULL) {
if (fam_connection == NULL)
{
fam_connection = g_new0 (FAMConnection, 1);
if (FAMOpen2 (fam_connection, "gvfs user") != 0) {
if (FAMOpen2 (fam_connection, "gvfs user") != 0)
{
g_warning ("FAMOpen failed, FAMErrno=%d\n", FAMErrno);
g_free (fam_connection);
fam_connection = NULL;
@ -187,7 +193,8 @@ _fam_sub_shutdown (void)
{
G_LOCK (fam_connection);
if (fam_connection != NULL) {
if (fam_connection != NULL)
{
FAMClose (fam_connection);
g_free (fam_connection);
g_source_remove (fam_watch_id);
@ -208,27 +215,29 @@ _fam_sub_add (const gchar* pathname,
if (!_fam_sub_startup ())
return NULL;
sub = g_new0 (fam_sub, 1);
sub->pathname = g_strdup (pathname);
sub->directory = directory;
sub->user_data = user_data;
G_LOCK (fam_connection);
/* We need to queue up incoming messages to avoid blocking on write
* if there are many monitors being canceled */
fam_do_iter_unlocked ();
if (fam_connection == NULL) {
if (fam_connection == NULL)
{
G_UNLOCK (fam_connection);
return NULL;
}
sub = g_new0 (fam_sub, 1);
sub->pathname = g_strdup (pathname);
sub->directory = directory;
sub->user_data = user_data;
if (directory)
FAMMonitorDirectory (fam_connection, pathname, &sub->request, sub);
else
FAMMonitorFile (fam_connection, pathname, &sub->request, sub);
G_UNLOCK (fam_connection);
return sub;
}
@ -245,7 +254,8 @@ _fam_sub_cancel (fam_sub* sub)
* if there are many monitors being canceled */
fam_do_iter_unlocked ();
if (fam_connection == NULL) {
if (fam_connection == NULL)
{
G_UNLOCK (fam_connection);
return FALSE;
}