[gegl] buffer: handle the case of direct gegl_free correctly
- From: Ãyvind KolÃs <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] buffer: handle the case of direct gegl_free correctly
- Date: Sat, 17 Mar 2012 23:15:36 +0000 (UTC)
commit 864bf0618369755f52ff36136f06e020898cc068
Author: Ãyvind KolÃs <pippin gimp org>
Date: Sat Mar 17 23:08:50 2012 +0000
buffer: handle the case of direct gegl_free correctly
gegl/buffer/gegl-tile.c | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/gegl/buffer/gegl-tile.c b/gegl/buffer/gegl-tile.c
index 0cad9cc..172cdb7 100644
--- a/gegl/buffer/gegl-tile.c
+++ b/gegl/buffer/gegl-tile.c
@@ -46,6 +46,8 @@ GeglTile *gegl_tile_ref (GeglTile *tile)
return tile;
}
+static int free_data_directly;
+
void gegl_tile_unref (GeglTile *tile)
{
if (!g_atomic_int_dec_and_test (&tile->ref_count))
@@ -62,11 +64,13 @@ void gegl_tile_unref (GeglTile *tile)
{
if (tile->next_shared == tile)
{ /* no clones */
-
if (tile->destroy_notify)
- tile->destroy_notify (tile->destroy_notify_data);
- else
- gegl_free (tile->data);
+ {
+ if (tile->destroy_notify == (void*)&free_data_directly)
+ gegl_free (tile->data);
+ else
+ tile->destroy_notify (tile->destroy_notify_data);
+ }
tile->data = NULL;
}
else
@@ -84,6 +88,7 @@ void gegl_tile_unref (GeglTile *tile)
g_slice_free (GeglTile, tile);
}
+
GeglTile *
gegl_tile_new_bare (void)
{
@@ -98,6 +103,9 @@ gegl_tile_new_bare (void)
tile->next_shared = tile;
tile->prev_shared = tile;
+ tile->destroy_notify = (void*)&free_data_directly;
+ tile->destroy_notify_data = NULL;
+
tile->mutex = g_mutex_new ();
return tile;
@@ -160,7 +168,7 @@ gegl_tile_unclone (GeglTile *tile)
* create a local copy
*/
tile->data = gegl_memdup (tile->data, tile->size);
- tile->destroy_notify = NULL;
+ tile->destroy_notify = (void*)&free_data_directly;
tile->destroy_notify_data = NULL;
tile->prev_shared->next_shared = tile->next_shared;
tile->next_shared->prev_shared = tile->prev_shared;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]