diff options
author | Tim Janik <timj@src.gnome.org> | 1998-01-30 23:47:09 +0000 |
---|---|---|
committer | Tim Janik <timj@src.gnome.org> | 1998-01-30 23:47:09 +0000 |
commit | 4af33fa24df69f335f07f43e5904a766c8d8ec97 (patch) | |
tree | ccc23ba16332f44ae45418f6cf9580036c4c76da /gdk/gdkgc.c | |
parent | ee7038f9fddd0213c65474e5d59609107caed7c6 (diff) | |
download | gdk-pixbuf-4af33fa24df69f335f07f43e5904a766c8d8ec97.tar.gz |
hm, initital refcount revolution commit ;)
still some gnits left, but keep working on it ;)
-timj
Diffstat (limited to 'gdk/gdkgc.c')
-rw-r--r-- | gdk/gdkgc.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/gdk/gdkgc.c b/gdk/gdkgc.c index d007fd6e6..7210acd8f 100644 --- a/gdk/gdkgc.c +++ b/gdk/gdkgc.c @@ -50,6 +50,7 @@ gdk_gc_new_with_values (GdkWindow *window, xwindow = window_private->xwindow; private->xdisplay = window_private->xdisplay; + private->ref_count = 1; xvalues.function = GXcopy; xvalues.fill_style = FillSolid; @@ -220,15 +221,35 @@ gdk_gc_new_with_values (GdkWindow *window, void gdk_gc_destroy (GdkGC *gc) { - GdkGCPrivate *private; + gdk_gc_unref (gc); +} - g_return_if_fail (gc != NULL); +GdkGC * +gdk_gc_ref (GdkGC *gc) +{ + GdkGCPrivate *private = (GdkGCPrivate*) gc; - private = (GdkGCPrivate*) gc; - XFreeGC (private->xdisplay, private->xgc); + g_return_val_if_fail (gc != NULL, NULL); + private->ref_count += 1; + + return gc; +} - memset (gc, 0, sizeof (GdkGCPrivate)); - g_free (gc); +void +gdk_gc_unref (GdkGC *gc) +{ + GdkGCPrivate *private = (GdkGCPrivate*) gc; + + g_return_if_fail (gc != NULL); + + if (private->ref_count > 1) + private->ref_count -= 1; + else + { + XFreeGC (private->xdisplay, private->xgc); + memset (gc, 0, sizeof (GdkGCPrivate)); + g_free (gc); + } } void |