Skip to content

Commit

Permalink
glib2: add a code for GC on process finish
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed May 25, 2018
1 parent 4688d7c commit 2e05cb3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions glib2/ext/glib2/rbglib-gc.c
Expand Up @@ -41,6 +41,7 @@ gc_marker_free(void *data)
{
GHashTable *hash_table = data;
g_hash_table_unref(hash_table);
rbg_objects = NULL;
}

static const rb_data_type_t rbg_gc_marker_type = {
Expand All @@ -58,6 +59,9 @@ static const rb_data_type_t rbg_gc_marker_type = {
void
rbg_gc_guard(gpointer key, VALUE rb_object)
{
if (!rbg_objects)
return;

g_hash_table_insert(rbg_objects,
key,
(gpointer)rb_object);
Expand All @@ -66,6 +70,9 @@ rbg_gc_guard(gpointer key, VALUE rb_object)
void
rbg_gc_unguard(gpointer key)
{
if (!rbg_objects)
return;

g_hash_table_remove(rbg_objects, key);
}

Expand Down

0 comments on commit 2e05cb3

Please sign in to comment.