static void ostree_chain_input_stream_finalize (GObject *object) { OstreeChainInputStream *stream; stream = (OstreeChainInputStream*)(object); g_ptr_array_unref (stream->priv->streams); G_OBJECT_CLASS (ostree_chain_input_stream_parent_class)->finalize (object); }
GtkWidget * empathy_contact_info_create_channel_list_label (TpAccount *account, GList *info, guint row) { GtkWidget *label = NULL; GString *label_markup = g_string_new (""); guint i; GPtrArray *channels; GList *l; /* Is there channels? */ channels = g_ptr_array_new (); for (l = info; l != NULL; l = l->next) { TpContactInfoField *field = l->data; if (!tp_strdiff (field->field_name, "x-irc-channel")) g_ptr_array_add (channels, (gpointer) field->field_value[0]); } if (channels->len == 0) goto out; for (i = 0; i < channels->len; i++) { const gchar *channel_name = g_ptr_array_index (channels, i); /* We abuse the URI of the link to hold the channel name. It seems to * be okay to just use it essentially verbatim, rather than trying to * ensure it's actually a valid URI. */ gchar *escaped = g_markup_escape_text (channel_name, -1); if (i > 0) g_string_append (label_markup, ", "); g_string_append_printf (label_markup, "<a href='%s'>%s</a>", escaped, escaped); g_free (escaped); } label = gtk_label_new (NULL); gtk_label_set_markup (GTK_LABEL (label), label_markup->str); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); g_signal_connect (label, "activate-link", (GCallback) channel_name_activated_cb, account); out: g_ptr_array_unref (channels); g_string_free (label_markup, TRUE); return label; }
static void fu_idle_finalize (GObject *obj) { FuIdle *self = FU_IDLE (obj); fu_idle_stop (self); g_ptr_array_unref (self->items); g_object_unref (self->items_mutex); G_OBJECT_CLASS (fu_idle_parent_class)->finalize (obj); }
static void parse_request_free (gpointer data) { ParseRequest *request = data; g_free (request->source_filename); g_strfreev (request->command_line_args); g_ptr_array_unref (request->unsaved_files); g_clear_object (&request->file); g_slice_free (ParseRequest, request); }
static void free_data (struct data *data) { donna_g_object_unref (data->pfs); if (data->loc_sources) g_hash_table_unref (data->loc_sources); if (data->ret_nodes) g_ptr_array_unref (data->ret_nodes); if (data->str) g_string_free (data->str, TRUE); g_slice_free (struct data, data); }
void message_new_view_deinit(struct MessageNewViewData *view) { if (view) { ui_utils_view_deinit(VIEW_PTR(*view)); g_ptr_array_foreach(view->recipients, _deinit_recipients_list, NULL); g_ptr_array_unref(view->recipients); } else { g_warning("Deiniting a new message view without view?"); } }
/** * pk_package_sack_finalize: **/ static void pk_package_sack_finalize (GObject *object) { PkPackageSack *sack = PK_PACKAGE_SACK (object); PkPackageSackPrivate *priv = sack->priv; g_ptr_array_unref (priv->array); g_hash_table_unref (priv->table); g_object_unref (priv->client); G_OBJECT_CLASS (pk_package_sack_parent_class)->finalize (object); }
static void gtk_snapshot_state_free (GtkSnapshotState *state) { g_ptr_array_unref (state->nodes); if (state->clip_region) cairo_region_destroy (state->clip_region); g_free (state->name); g_slice_free (GtkSnapshotState, state); }
static void as_content_rating_finalize (GObject *object) { AsContentRating *content_rating = AS_CONTENT_RATING (object); AsContentRatingPrivate *priv = GET_PRIVATE (content_rating); if (priv->kind != NULL) as_ref_string_unref (priv->kind); g_ptr_array_unref (priv->keys); G_OBJECT_CLASS (as_content_rating_parent_class)->finalize (object); }
END_TEST START_TEST(test_sltr_provides_glob) { HySelector sltr = hy_selector_create(test_globals.sack); fail_if(hy_selector_set(sltr, HY_PKG_PROVIDES, HY_GLOB, "*alru*")); GPtrArray *plist = hy_selector_matches(sltr); fail_unless(plist->len == 2); g_ptr_array_unref(plist); hy_selector_free(sltr); }
void gst_cenc_decrypt_dispose (GObject * object) { GstCencDecrypt *self = GST_CENC_DECRYPT (object); if (self->keys) { g_ptr_array_unref (self->keys); self->keys = NULL; } G_OBJECT_CLASS (parent_class)->dispose (object); }
/** * pk_debuginfo_install_resolve_name_to_id: **/ static gchar * pk_debuginfo_install_resolve_name_to_id (PkDebuginfoInstallPrivate *priv, const gchar *package_name, GError **error) { PkResults *results = NULL; PkPackage *item; gchar *package_id = NULL; GPtrArray *list = NULL; GError *error_local = NULL; gchar **names; PkError *error_code = NULL; /* resolve takes a char** */ names = g_strsplit (package_name, ";", -1); /* resolve */ results = pk_client_resolve (priv->client, pk_bitfield_from_enums (PK_FILTER_ENUM_NEWEST, -1), names, NULL, NULL, NULL, &error_local); if (results == NULL) { *error = g_error_new (1, 0, "failed to resolve: %s", error_local->message); g_error_free (error_local); goto out; } /* check error code */ error_code = pk_results_get_error_code (results); if (error_code != NULL) { *error = g_error_new (1, 0, "failed to resolve: %s, %s", pk_error_enum_to_string (pk_error_get_code (error_code)), pk_error_get_details (error_code)); goto out; } /* check we only got one match */ list = pk_results_get_package_array (results); if (list->len == 0) { *error = g_error_new (1, 0, "no package %s found", package_name); goto out; } if (list->len > 1) { *error = g_error_new (1, 0, "more than one package found for %s", package_name); goto out; } /* get the package id */ item = g_ptr_array_index (list, 0); package_id = g_strdup (pk_package_get_id (item)); out: if (error_code != NULL) g_object_unref (error_code); if (results != NULL) g_object_unref (results); if (list != NULL) g_ptr_array_unref (list); g_strfreev (names); return package_id; }
static PyObject * obsoleted_by_package(_GoalObject *self, PyObject *pkg) { HifPackage *cpkg = packageFromPyObject(pkg); if (cpkg == NULL) return NULL; GPtrArray *plist = hy_goal_list_obsoleted_by_package(self->goal, cpkg); PyObject *list = packagelist_to_pylist(plist, self->sack); g_ptr_array_unref(plist); return list; }
void handle_destory_storage(void) { pthread_mutex_lock(&lock); g_ptr_array_unref(vdpHandles); g_hash_table_unref(xdpy_copies); g_hash_table_unref(xdpy_copies_refcount); vdpHandles = NULL; xdpy_copies = NULL; xdpy_copies_refcount = NULL; pthread_mutex_unlock(&lock); }
/** * mcm_calibrate_dialog_finalize: **/ static void mcm_calibrate_dialog_finalize (GObject *object) { McmCalibrateDialog *calibrate_dialog = MCM_CALIBRATE_DIALOG (object); McmCalibrateDialogPrivate *priv = calibrate_dialog->priv; g_object_unref (priv->builder); g_ptr_array_unref (priv->cached_dialogs); g_main_loop_unref (priv->loop); G_OBJECT_CLASS (mcm_calibrate_dialog_parent_class)->finalize (object); }
/** * as_pool_save_cache_file: * @pool: An instance of #AsPool. * @fname: Filename of the cache file the pool contents should be dumped to. * @error: A #GError or %NULL. * * Serialize AppStream metadata to a cache file. */ gboolean as_pool_save_cache_file (AsPool *pool, const gchar *fname, GError **error) { AsPoolPrivate *priv = GET_PRIVATE (pool); g_autoptr(GPtrArray) cpts = NULL; cpts = as_pool_get_components (pool); as_cache_file_save (fname, priv->locale, cpts, error); g_ptr_array_unref (cpts); return TRUE; }
GtkBitmask * _gtk_css_computed_values_advance (GtkCssComputedValues *values, gint64 timestamp) { GtkBitmask *changed; GPtrArray *old_computed_values; GSList *list; guint i; gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL); gtk_internal_return_val_if_fail (timestamp >= values->current_time, NULL); values->current_time = timestamp; old_computed_values = values->animated_values; values->animated_values = NULL; list = values->animations; while (list) { GtkStyleAnimation *animation = list->data; list = list->next; _gtk_style_animation_set_values (animation, timestamp, GTK_CSS_COMPUTED_VALUES (values)); if (_gtk_style_animation_is_finished (animation, timestamp)) { values->animations = g_slist_remove (values->animations, animation); g_object_unref (animation); } } /* figure out changes */ changed = _gtk_bitmask_new (); for (i = 0; i < GTK_CSS_PROPERTY_N_PROPERTIES; i++) { GtkCssValue *old_animated, *new_animated; old_animated = old_computed_values && i < old_computed_values->len ? g_ptr_array_index (old_computed_values, i) : NULL; new_animated = values->animated_values && i < values->animated_values->len ? g_ptr_array_index (values->animated_values, i) : NULL; if (!_gtk_css_value_equal0 (old_animated, new_animated)) changed = _gtk_bitmask_set (changed, i, TRUE); } if (old_computed_values) g_ptr_array_unref (old_computed_values); return changed; }
static void clutter_gst_overlays_free (gpointer data) { if (G_LIKELY (data)) { ClutterGstOverlays *overlays = (ClutterGstOverlays *) data; g_ptr_array_unref (overlays->overlays); g_slice_free (ClutterGstOverlays, overlays); } }
static void execute_print(HifSack *sack, HyQuery q, int show_obsoletes) { GPtrArray *plist; plist = hy_query_run(q); const int count = plist->len; for (int i = 0; i < count; ++i) { HifPackage *pkg = g_ptr_array_index(plist, i); const char *nvra = hif_package_get_nevra(pkg); const char *reponame = hif_package_get_reponame(pkg); printf("found package: %s [%s]\n", nvra, reponame); if (strcmp(reponame, HY_SYSTEM_REPO_NAME) == 0) { int type; const unsigned char * hdrid = hif_package_get_hdr_chksum(pkg, &type); char *str = hy_chksum_str(hdrid, type); printf("\tsha1 header id: %s\n", str); g_free(str); } if (show_obsoletes) { HifReldepList *obsoletes = hif_package_get_obsoletes(pkg); HyQuery qobs = hy_query_create(sack); hy_query_filter(qobs, HY_PKG_REPONAME, HY_NEQ, HY_SYSTEM_REPO_NAME); hy_query_filter_reldep_in(qobs, HY_PKG_PROVIDES, obsoletes); GPtrArray *olist = hy_query_run(qobs); const int ocount = olist->len; for (int j = 0; j < ocount; ++j) { HifPackage *opkg = g_ptr_array_index(olist, j); const char *onvra = hif_package_get_nevra(opkg); printf("obsoleting: %s\n", onvra); } g_ptr_array_unref(olist); hy_query_free(qobs); g_object_unref(obsoletes); } } g_ptr_array_unref(plist); }
static struct beans_content_s * _beans_to_content(const GSList *beans) { struct beans_content_s *c = g_malloc0(sizeof(struct beans_content_s)); GPtrArray *contents, *chunks; chunk_pair_t pair; contents = g_ptr_array_new(); chunks = g_ptr_array_new(); /*dispatch */ for(; beans; beans = beans->next) { if (DESCR(beans->data) == &descr_struct_CHUNKS) g_ptr_array_add(chunks, _bean_dup(beans->data)); else if (DESCR(beans->data) == &descr_struct_CONTENTS) g_ptr_array_add(contents, _bean_dup(beans->data)); else if (DESCR(beans->data) == &descr_struct_CONTENTS_HEADERS) c->header = _bean_dup(beans->data); else if (DESCR(beans->data) == &descr_struct_ALIASES) c->alias = _bean_dup(beans->data); else if (DESCR(beans->data) == &descr_struct_PROPERTIES) c->properties = g_slist_append(c->properties, _bean_dup(beans->data)); } /* build pairs */ c->pairs = g_array_new(FALSE, FALSE, sizeof(chunk_pair_t)); for(guint i=0; i < contents->len ; i++) { init_chunk_pair(chunks, &pair, g_ptr_array_index(contents, i)); if(pair.chunk != NULL) g_array_append_vals(c->pairs, &pair, 1); } g_array_sort(c->pairs, (GCompareFunc) compare_pairs_positions); // what we want to preserve are the pointers to beans created by // _bean_dup, not the GPtrArray -> we can safely free the arrays. g_ptr_array_unref(contents); g_ptr_array_unref(chunks); return c; }
static void mex_program_finalize (GObject *object) { MexProgram *self = (MexProgram *) object; MexProgramPrivate *priv = self->priv; if (priv->actors) { g_ptr_array_unref (priv->actors); priv->actors = NULL; } G_OBJECT_CLASS (mex_program_parent_class)->finalize (object); }
static DnfPackage * get_available_pkg(DnfSack *sack, const char *name) { HyQuery q = hy_query_create(sack); hy_query_filter(q, HY_PKG_NAME, HY_EQ, name); hy_query_filter(q, HY_PKG_REPONAME, HY_NEQ, HY_SYSTEM_REPO_NAME); GPtrArray *plist = hy_query_run(q); fail_unless(plist->len == 1); DnfPackage *pkg = g_object_ref(g_ptr_array_index(plist, 0)); hy_query_free(q); g_ptr_array_unref(plist); return pkg; }
END_TEST START_TEST(test_sltr_matching) { HySelector sltr = hy_selector_create(test_globals.sack); fail_if(hy_selector_set(sltr, HY_PKG_NAME, HY_EQ, "penny")); GPtrArray *plist = hy_selector_matches(sltr); fail_unless(plist->len == 2); g_ptr_array_unref(plist); hy_selector_free(sltr); }
/** * egg_debug_free: **/ static void egg_debug_free (void) { if (!_initialized) return; /* close file */ if (_fd != -1) close (_fd); /* free memory */ g_free (_log_filename); if (_modules_array != NULL) g_ptr_array_unref (_modules_array); if (_functions_array != NULL) g_ptr_array_unref (_functions_array); g_strfreev (_modules); g_strfreev (_functions); /* can not re-init */ _initialized = FALSE; }
static GVariant * ip6_routes_get (NMSetting *setting, const char *property) { GPtrArray *routes; GVariant *ret; g_object_get (setting, property, &routes, NULL); ret = nm_utils_ip6_routes_to_variant (routes); g_ptr_array_unref (routes); return ret; }
static gboolean barebox_state_get_int(const gchar* name, int *value) { GSubprocess *sub; GError *error = NULL; gboolean res = FALSE; GInputStream *instream; GDataInputStream *datainstream; gchar* outline; guint64 result = 0; GPtrArray *args = g_ptr_array_new_full(10, g_free); g_ptr_array_add(args, g_strdup(BAREBOX_STATE_NAME)); g_ptr_array_add(args, g_strdup("-g")); g_ptr_array_add(args, g_strdup(name)); g_ptr_array_add(args, NULL); sub = g_subprocess_newv((const gchar * const *)args->pdata, G_SUBPROCESS_FLAGS_NONE, &error); if (!sub) { g_warning("getting state failed: %s", error->message); g_clear_error(&error); goto out; } instream = g_subprocess_get_stdout_pipe(sub); datainstream = g_data_input_stream_new(instream); outline = g_data_input_stream_read_line(datainstream, NULL, NULL, NULL); if (!outline) { g_warning("failed reading state"); goto out; } result = g_ascii_strtoull(outline, NULL, 10); if (errno != 0) { g_warning("Invalid return value: '%s'\n", outline); goto out; } res = g_subprocess_wait_check(sub, NULL, &error); if (!res) { g_warning("getting state failed: %s", error->message); g_clear_error(&error); goto out; } out: g_ptr_array_unref(args); *value = result; return res; }
void print_dates_sorted (void) { /* Choose five dates randomly from a time interval, sort them, and send to stdio. */ GTimeZone *tz; GPtrArray *dates; GDateTime *dt; gchar *str; gint i; tz = (GTimeZone *)g_time_zone_new_local(); dates = g_ptr_array_new(); g_ptr_array_set_free_func(dates, (GDestroyNotify)g_date_time_unref); /* * Insert some random dates into the array. */ for (i = 0; i < 5; i++) { dt = (GDateTime *)g_date_time_new(tz, g_random_int_range(1900, 2020), g_random_int_range(1, 12), g_random_int_range(1, 28), 0, 0, 0); g_ptr_array_add(dates, dt); } /* * Sort dates. Remember that GPtrArray returns a pointer to the * pointer type in sorting methods so they need to be dereferenced. */ g_ptr_array_sort(dates, gdt_sorter); /* * Print out the dates */ g_print("Dates sorted in order:\n"); for (i = 0; i < dates->len; i++) { dt = g_ptr_array_index(dates, i); str = g_date_time_format(dt, "%b %d, %Y"); g_print(" %s\n", str); g_free(str); } g_ptr_array_unref(dates); g_time_zone_unref(tz); }
static gboolean photos_search_provider_get_result_metas (PhotosSearchProvider *self, GDBusMethodInvocation *invocation, const gchar *const *identifiers) { GApplication *app; GPtrArray *to_fetch_arr; const gchar *const *to_fetch; guint i; guint n_identifiers; guint n_to_fetch; app = g_application_get_default (); g_application_hold (app); n_identifiers = g_strv_length ((gchar **) identifiers); to_fetch_arr = g_ptr_array_sized_new (n_identifiers + 1); for (i = 0; identifiers[i] != NULL; i++) { if (g_hash_table_lookup (self->cache, identifiers[i]) == NULL) g_ptr_array_add (to_fetch_arr, (gpointer) identifiers[i]); } g_ptr_array_add (to_fetch_arr, NULL); to_fetch = (const gchar * const *) to_fetch_arr->pdata; n_to_fetch = g_strv_length ((gchar **) to_fetch); if (n_to_fetch > 0) { PhotosFetchMetasJob *job; job = photos_fetch_metas_job_new (to_fetch); g_object_set_data_full (G_OBJECT (invocation), "identifiers", g_boxed_copy (G_TYPE_STRV, identifiers), (GDestroyNotify) g_strfreev); g_object_set_data_full (G_OBJECT (invocation), "self", g_object_ref (self), g_object_unref); photos_fetch_metas_job_run (job, self->state, photos_search_provider_fetch_metas_executed, g_object_ref (invocation)); g_object_unref (job); } else photos_search_provider_return_metas_from_cache (self, identifiers, invocation); g_ptr_array_unref (to_fetch_arr); return TRUE; }
static void erase(HifSack *sack, const char *name) { HyQuery q = hy_query_create(sack); hy_query_filter(q, HY_PKG_NAME, HY_EQ, name); hy_query_filter(q, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME); GPtrArray *plist = hy_query_run(q); if (plist->len < 1) { printf("No installed package to erase found.\n"); goto finish; } if (plist->len > 1) printf("(more than one updatables found, selecting the first one)\n"); HyGoal goal = hy_goal_create(sack); hy_goal_erase(goal, g_ptr_array_index(plist, 0)); if (hy_goal_run(goal)) { dump_goal_errors(goal); hy_goal_free(goal); goto finish; } g_ptr_array_unref(plist); plist = hy_goal_list_erasures(goal, NULL); printf("erasure count: %d\n", plist->len); for (unsigned int i = 0; i < plist->len; ++i) { HifPackage *pkg = g_ptr_array_index(plist, i); const char *nvra = hif_package_get_nevra(pkg); printf("erasing %s\n", nvra); } hy_goal_free(goal); finish: g_ptr_array_unref(plist); hy_query_free(q); }
static void gst_device_monitor_dispose (GObject * object) { GstDeviceMonitor *self = GST_DEVICE_MONITOR (object); g_return_if_fail (!self->priv->started); if (self->priv->providers) { while (self->priv->providers->len) gst_device_monitor_remove (self, self->priv->providers->len - 1); g_ptr_array_unref (self->priv->providers); self->priv->providers = NULL; } if (self->priv->filters) { g_ptr_array_unref (self->priv->filters); self->priv->filters = NULL; } gst_object_replace ((GstObject **) & self->priv->bus, NULL); G_OBJECT_CLASS (gst_device_monitor_parent_class)->dispose (object); }