[gjs] Fix object counters



commit b0557046f3551c90449cd60a2bcbe66d40851281
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Wed Jul 4 22:28:57 2012 +0200

    Fix object counters
    
    Previously object counters were defined as int, which allowed them
    to be negative. Replacing with unsigned int revealed a number of
    places where we weren't incrementing properly, in particular in
    dynamic class definitions (prototypes are finalized, and thus would
    decrement the counter).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=679688

 gi/boxed.c     |    3 +++
 gi/gerror.c    |    2 ++
 gi/interface.c |    1 +
 gi/object.c    |    1 +
 gi/param.c     |    1 +
 gi/union.c     |    2 ++
 gjs/mem.h      |    2 +-
 7 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/gi/boxed.c b/gi/boxed.c
index 1168ae4..650d4e3 100644
--- a/gi/boxed.c
+++ b/gi/boxed.c
@@ -594,6 +594,7 @@ get_nested_interface_object (JSContext   *context,
     if (obj == NULL)
         return JS_FALSE;
 
+    GJS_INC_COUNTER(boxed);
     priv = g_slice_new0(Boxed);
     JS_SetPrivate(context, obj, priv);
     priv->info = (GIBoxedInfo*) interface_info;
@@ -1159,6 +1160,7 @@ gjs_define_boxed_class(JSContext    *context,
 
     g_assert(gjs_object_has_property(context, in_object, constructor_name));
 
+    GJS_INC_COUNTER(boxed);
     priv = g_slice_new0(Boxed);
     priv->info = info;
     g_base_info_ref( (GIBaseInfo*) priv->info);
@@ -1224,6 +1226,7 @@ gjs_boxed_from_c_struct(JSContext             *context,
                                      JS_GET_CLASS(context, proto), proto,
                                      gjs_get_import_global (context));
 
+    GJS_INC_COUNTER(boxed);
     priv = g_slice_new0(Boxed);
     JS_SetPrivate(context, obj, priv);
     priv->info = info;
diff --git a/gi/gerror.c b/gi/gerror.c
index 45dc387..b5ec1ab 100644
--- a/gi/gerror.c
+++ b/gi/gerror.c
@@ -461,6 +461,7 @@ gjs_define_error_class(JSContext    *context,
 
     g_assert(gjs_object_has_property(context, in_object, constructor_name));
 
+    GJS_INC_COUNTER(gerror);
     priv = g_slice_new0(Error);
     priv->info = info;
     g_base_info_ref( (GIBaseInfo*) priv->info);
@@ -611,6 +612,7 @@ gjs_error_from_gerror(JSContext             *context,
                                      JS_GET_CLASS(context, proto), proto,
                                      gjs_get_import_global (context));
 
+    GJS_INC_COUNTER(gerror);
     priv = g_slice_new0(Error);
     JS_SetPrivate(context, obj, priv);
     priv->info = info;
diff --git a/gi/interface.c b/gi/interface.c
index 9ee7603..c8147b2 100644
--- a/gi/interface.c
+++ b/gi/interface.c
@@ -255,6 +255,7 @@ gjs_define_interface_class(JSContext       *context,
 
     g_assert(gjs_object_has_property(context, in_object, constructor_name));
 
+    GJS_INC_COUNTER(interface);
     priv = g_slice_new0(Interface);
     priv->info = info;
     priv->gtype = g_registered_type_info_get_g_type(priv->info);
diff --git a/gi/object.c b/gi/object.c
index f4d5e26..7586b13 100644
--- a/gi/object.c
+++ b/gi/object.c
@@ -1727,6 +1727,7 @@ gjs_define_object_class(JSContext     *context,
 
     g_assert(gjs_object_has_property(context, in_object, constructor_name));
 
+    GJS_INC_COUNTER(object);
     priv = g_slice_new0(ObjectInstance);
     priv->info = info;
     if (info)
diff --git a/gi/param.c b/gi/param.c
index f4576b0..ae7bed5 100644
--- a/gi/param.c
+++ b/gi/param.c
@@ -594,6 +594,7 @@ gjs_param_from_g_param(JSContext    *context,
                                      JS_GET_CLASS(context, proto), proto,
                                      gjs_get_import_global (context));
 
+    GJS_INC_COUNTER(param);
     priv = g_slice_new0(Param);
     JS_SetPrivate(context, obj, priv);
     priv->gparam = gparam;
diff --git a/gi/union.c b/gi/union.c
index a714728..36e9f4b 100644
--- a/gi/union.c
+++ b/gi/union.c
@@ -450,6 +450,7 @@ gjs_define_union_class(JSContext    *context,
 
     g_assert(gjs_object_has_property(context, in_object, constructor_name));
 
+    GJS_INC_COUNTER(boxed);
     priv = g_slice_new0(Union);
     priv->info = info;
     g_base_info_ref( (GIBaseInfo*) priv->info);
@@ -514,6 +515,7 @@ gjs_union_from_c_union(JSContext    *context,
                                      JS_GET_CLASS(context, proto), proto,
                                      gjs_get_import_global (context));
 
+    GJS_INC_COUNTER(boxed);
     priv = g_slice_new0(Union);
     JS_SetPrivate(context, obj, priv);
     priv->info = info;
diff --git a/gjs/mem.h b/gjs/mem.h
index 7efe51b..3179c6e 100644
--- a/gjs/mem.h
+++ b/gjs/mem.h
@@ -34,7 +34,7 @@
 G_BEGIN_DECLS
 
 typedef struct {
-    int value;
+    unsigned int value;
     const char *name;
 } GjsMemCounter;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]