empathy r1840 - trunk/libempathy
- From: xclaesse svn gnome org
- To: svn-commits-list gnome org
- Subject: empathy r1840 - trunk/libempathy
- Date: Fri, 21 Nov 2008 16:20:20 +0000 (UTC)
Author: xclaesse
Date: Fri Nov 21 16:20:20 2008
New Revision: 1840
URL: http://svn.gnome.org/viewvc/empathy?rev=1840&view=rev
Log:
Renamed free_copy_data_if_closed to copy_data_unref and have a ref_count in the CopyData struct. (Jonny Lamb)
Signed-off-by: Jonny Lamb <jonny lamb collabora co uk>
Modified:
trunk/libempathy/empathy-tp-file.c
Modified: trunk/libempathy/empathy-tp-file.c
==============================================================================
--- trunk/libempathy/empathy-tp-file.c (original)
+++ trunk/libempathy/empathy-tp-file.c Fri Nov 21 16:20:20 2008
@@ -79,32 +79,36 @@
gboolean is_reading; /* we are reading */
gboolean is_writing; /* we are writing */
guint n_closed; /* number of streams that have been closed */
+ gint ref_count;
} CopyData;
static void schedule_next (CopyData *copy);
static void
-free_copy_data_if_closed (CopyData *copy)
+copy_data_unref (CopyData *copy)
{
- gint i;
+ if (--copy->ref_count == 0)
+ {
+ gint i;
- /* Free the data only if both the input and output streams have
- * been closed. */
- copy->n_closed++;
- if (copy->n_closed < 2)
- return;
+ /* Free the data only if both the input and output streams have
+ * been closed. */
+ copy->n_closed++;
+ if (copy->n_closed < 2)
+ return;
- if (copy->in != NULL)
- g_object_unref (copy->in);
+ if (copy->in != NULL)
+ g_object_unref (copy->in);
- if (copy->out != NULL)
- g_object_unref (copy->out);
+ if (copy->out != NULL)
+ g_object_unref (copy->out);
- for (i = 0; i < N_BUFFERS; i++)
- g_free (copy->buff[i]);
+ for (i = 0; i < N_BUFFERS; i++)
+ g_free (copy->buff[i]);
- g_object_unref (copy->cancellable);
- g_free (copy);
+ g_object_unref (copy->cancellable);
+ g_free (copy);
+ }
}
static void
@@ -126,7 +130,7 @@
if (copy->out != NULL)
g_output_stream_close (copy->out, NULL, NULL);
- free_copy_data_if_closed (copy);
+ copy_data_unref (copy);
}
static void
@@ -137,7 +141,7 @@
CopyData *copy = user_data;
g_object_unref (source_object);
- free_copy_data_if_closed (copy);
+ copy_data_unref (copy);
}
static void
@@ -254,6 +258,7 @@
copy = g_new0 (CopyData, 1);
copy->in = g_object_ref (in);
copy->out = g_object_ref (out);
+ copy->ref_count = 1;
if (cancellable != NULL)
copy->cancellable = g_object_ref (cancellable);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]