static void keep_alive_finalize(JSContext *context, JSObject *obj) { KeepAlive *priv; void *key; void *value; priv = priv_from_js(context, obj); gjs_debug_lifecycle(GJS_DEBUG_KEEP_ALIVE, "keep_alive finalizing, obj %p priv %p", obj, priv); if (priv == NULL) return; /* we are the prototype, not a real instance, so constructor never called */ priv->inside_finalize = TRUE; while (gjs_g_hash_table_steal_one(priv->children, &key, &value)) { Child *child = value; if (child->notify) (* child->notify) (child->child, child->data); child_free(child); } g_hash_table_destroy(priv->children); g_slice_free(KeepAlive, priv); }
static void keep_alive_finalize(JSFreeOp *fop, JSObject *obj) { KeepAlive *priv; void *key; void *value; priv = (KeepAlive *) JS_GetPrivate(obj); gjs_debug_lifecycle(GJS_DEBUG_KEEP_ALIVE, "keep_alive finalizing, obj %p priv %p", obj, priv); if (priv == NULL) return; /* we are the prototype, not a real instance */ priv->inside_finalize = true; while (gjs_g_hash_table_steal_one(priv->children, &key, &value)) { Child *child = (Child *) value; if (child->notify) (* child->notify) (child->child, child->data); child_free(child); } g_hash_table_destroy(priv->children); g_slice_free(KeepAlive, priv); }