Commit 7a74a26e authored by Michael Henning's avatar Michael Henning

buffer: stop leaking the buffer pool in gegl-buffer-iterator.

parent 00bbe08e
/* This file is part of GEGL.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2013 Michael Henning <drawoc@darkrefraction.com>
*/
#ifndef __GEGL_BUFFER_ITERATOR_PRIVATE_H__
#define __GEGL_BUFFER_ITERATOR_PRIVATE_H__
void _gegl_buffer_iterator_cleanup (void);
#endif
......@@ -322,10 +322,6 @@ gegl_buffer_iterator_add (GeglBufferIterator *iterator,
return self;
}
/* FIXME: we are currently leaking this buf pool, it should be
* freed when gegl is uninitialized
*/
typedef struct BufInfo {
gint size;
gint used; /* if this buffer is currently allocated */
......@@ -382,6 +378,24 @@ static void iterator_buf_pool_release (gpointer buf)
g_mutex_unlock (&pool_mutex);
}
void
_gegl_buffer_iterator_cleanup ()
{
gint i;
/* FIXME: is the mutex lock necessary? */
g_mutex_lock (&pool_mutex);
if (buf_pool) {
for (i=0; i<buf_pool->len; i++)
{
BufInfo *info = &g_array_index (buf_pool, BufInfo, i);
gegl_free (info->buf);
}
g_array_free (buf_pool, TRUE);
buf_pool = NULL;
}
g_mutex_unlock (&pool_mutex);
}
static void ensure_buf (GeglBufferIterators *i, gint no)
{
if (i->buf[no]==NULL)
......
......@@ -92,6 +92,7 @@ guint gegl_debug_flags = 0;
#include "operation/gegl-operations.h"
#include "operation/gegl-extension-handler.h"
#include "buffer/gegl-buffer-private.h"
#include "buffer/gegl-buffer-iterator-private.h"
#include "buffer/gegl-tile-backend-ram.h"
#include "buffer/gegl-tile-backend-tiledir.h"
#include "buffer/gegl-tile-backend-file.h"
......@@ -397,6 +398,7 @@ gegl_exit (void)
gegl_tile_cache_destroy ();
gegl_operation_gtype_cleanup ();
gegl_extension_handler_cleanup ();
_gegl_buffer_iterator_cleanup ();
if (module_db != NULL)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment