/* This does preprocessing including handling of "other lint" (non-dupes) * After rm_preprocess(), all remaining duplicate candidates are in * a jagged GSList of GSLists as follows: * session->tables->size_groups->group1->file1a * ->file1b * ->file1c * ->group2->file2a * ->file2b * etc */ void rm_preprocess(RmSession *session) { RmFileTables *tables = session->tables; GQueue *all_files = tables->all_files; session->total_filtered_files = session->total_files; /* initial sort by size */ g_queue_sort(all_files, (GCompareDataFunc)rm_file_cmp_full, session); rm_log_debug_line("initial size sort finished at time %.3f; sorted %d files", g_timer_elapsed(session->timer, NULL), session->total_files); /* split into file size groups; for each size, remove path doubles and bundle * hardlinks */ rm_assert_gentle(all_files->head); RmFile *file = g_queue_pop_head(all_files); RmFile *current_size_file = file; guint removed = 0; GHashTable *node_table = tables->node_table; while(file && !rm_session_was_aborted()) { /* group files into inode clusters */ GQueue *inode_cluster = rm_hash_table_setdefault(node_table, file, (RmNewFunc)g_queue_new); g_queue_push_tail(inode_cluster, file); /* get next file and check if it is part of the same group */ file = g_queue_pop_head(all_files); if(!file || rm_file_cmp_split(file, current_size_file, session) != 0) { /* process completed group (all same size & other criteria)*/ /* remove path doubles and handle "other" lint */ /* add an empty GSlist to our list of lists */ tables->size_groups = g_slist_prepend(tables->size_groups, NULL); removed += g_hash_table_foreach_remove( node_table, (GHRFunc)rm_pp_handle_inode_clusters, session); /* free up the node table for the next group */ g_hash_table_steal_all(node_table); if(tables->size_groups->data == NULL) { /* zero size group after handling other lint; remove it */ tables->size_groups = g_slist_delete_link(tables->size_groups, tables->size_groups); } } current_size_file = file; } session->other_lint_cnt += rm_pp_handler_other_lint(session); rm_log_debug_line( "path doubles removal/hardlink bundling/other lint finished at %.3f; removed %u " "of %d", g_timer_elapsed(session->timer, NULL), removed, session->total_files); rm_fmt_set_state(session->formats, RM_PROGRESS_STATE_PREPROCESS); }
gboolean mkp_project_move (MkpProject *project, const gchar *path) { GFile *old_root_file; GFile *new_file; gchar *relative; GHashTableIter iter; gpointer key; gpointer value; AnjutaTokenFile *tfile; GHashTable* old_hash; /* Change project root directory */ old_root_file = project->root_file; project->root_file = g_file_new_for_path (path); /* Change project root directory in groups */ old_hash = project->groups; project->groups = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); g_hash_table_iter_init (&iter, old_hash); while (g_hash_table_iter_next (&iter, &key, &value)) { MkpGroup *group = (MkpGroup *)value; relative = get_relative_path (old_root_file, group->base.file); new_file = g_file_resolve_relative_path (project->root_file, relative); g_free (relative); g_object_unref (group->base.file); group->base.file = new_file; g_hash_table_insert (project->groups, g_file_get_uri (new_file), group); } g_hash_table_destroy (old_hash); /* Change all files */ old_hash = project->files; project->files = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, g_object_unref, g_object_unref); g_hash_table_iter_init (&iter, old_hash); while (g_hash_table_iter_next (&iter, &key, (gpointer *)&tfile)) { relative = get_relative_path (old_root_file, anjuta_token_file_get_file (tfile)); new_file = g_file_resolve_relative_path (project->root_file, relative); g_free (relative); anjuta_token_file_move (tfile, new_file); g_hash_table_insert (project->files, new_file, tfile); g_object_unref (key); } g_hash_table_steal_all (old_hash); g_hash_table_destroy (old_hash); g_object_unref (old_root_file); return TRUE; }
static void _epris_dbus_proxy_get_all_reply (EprisDBusProxy* self, GHashTable* props, GError* err) { char* _tmp6_; g_return_if_fail (self != NULL); g_return_if_fail (props != NULL); if (err != NULL) { g_warning (err->message); return; } { GList* key_collection; GList* key_it; key_collection = g_hash_table_get_keys (props); for (key_it = key_collection; key_it != NULL; key_it = key_it->next) { const char* key; key = (const char*) key_it->data; { GValue* _tmp0_; GValue* v; char* _tmp4_; char* _tmp3_; char* _tmp2_; char* _tmp1_; GValue* _tmp5_; _tmp0_ = NULL; v = (_tmp0_ = (GValue*) g_hash_table_lookup (props, key), (_tmp0_ == NULL) ? NULL : _g_value_dup (_tmp0_)); _tmp4_ = NULL; _tmp3_ = NULL; _tmp2_ = NULL; _tmp1_ = NULL; g_message (_tmp4_ = g_strconcat (_tmp2_ = g_strconcat (_tmp1_ = g_strconcat ("key ", key, NULL), " ", NULL), _tmp3_ = g_strdup_value_contents (v), NULL)); _tmp4_ = (g_free (_tmp4_), NULL); _tmp3_ = (g_free (_tmp3_), NULL); _tmp2_ = (g_free (_tmp2_), NULL); _tmp1_ = (g_free (_tmp1_), NULL); _tmp5_ = NULL; epris_structure_set ((EprisStructure*) self, key, (_tmp5_ = v, (_tmp5_ == NULL) ? NULL : _g_value_dup (_tmp5_))); (v == NULL) ? NULL : (v = (g_free (v), NULL)); } } (key_collection == NULL) ? NULL : (key_collection = (g_list_free (key_collection), NULL)); } g_hash_table_steal_all (props); _tmp6_ = NULL; g_message (_tmp6_ = epris_structure_to_string ((EprisStructure*) self)); _tmp6_ = (g_free (_tmp6_), NULL); epris_dbus_proxy_set_updated (self, TRUE); }
void conscience_srvtype_flush(struct conscience_srvtype_s *srvtype) { guint counter; struct conscience_srv_s *beacon, *cur, *nxt; if (!srvtype) return; g_hash_table_steal_all(srvtype->services_ht); counter = 0; beacon = &(srvtype->services_ring); for (cur = beacon->next; cur && cur != beacon; cur = nxt) { nxt = cur->next; conscience_srv_destroy(cur); counter++; } DEBUG("Service type [%s] flushed, [%u] services removed", srvtype->type_name, counter); }
static GList * get_places_list (void) { GList *list, *l; GHashTable *places; Place *place, *old_place; GList *places_list; places = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal, NULL, (GDestroyNotify) place_free); /* add home */ place = g_slice_new0 (Place); place->location = g_file_new_for_path (g_get_home_dir ()); place->place_type = PLACE_XDG; place->display_name = g_strdup (_("Home")); g_hash_table_insert (places, place->location, place); /* first, load the XDG dirs */ list = get_xdg_dirs (); for (l = list; l != NULL; l = l->next) { place = l->data; g_hash_table_insert (places, place->location, place); } g_list_free (list); /* then, insert all the tracker locations that are not XDG dirs */ list = get_tracker_locations (); for (l = list; l != NULL; l = l->next) { place = l->data; old_place = g_hash_table_lookup (places, place->location); if (old_place == NULL) g_hash_table_insert (places, place->location, place); else place_free (place); } g_list_free (list); /* finally, load bookmarks, and possibly update attributes */ list = get_bookmarks (); for (l = list; l != NULL; l = l->next) { place = l->data; old_place = g_hash_table_lookup (places, place->location); if (old_place == NULL) { g_hash_table_insert (places, place->location, place); } else { g_free (old_place->display_name); old_place->display_name = g_strdup (place->display_name); if (old_place->place_type == PLACE_OTHER) old_place->place_type = PLACE_BOOKMARKS; place_free (place); } } g_list_free (list); places_list = g_hash_table_get_values (places); g_hash_table_steal_all (places); g_hash_table_unref (places); return places_list; }
void _pygi_argument_release (GIArgument *arg, GITypeInfo *type_info, GITransfer transfer, GIDirection direction) { GITypeTag type_tag; gboolean is_out = (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT); type_tag = g_type_info_get_tag (type_info); switch (type_tag) { case GI_TYPE_TAG_VOID: /* Don't do anything, it's transparent to the C side */ break; case GI_TYPE_TAG_BOOLEAN: case GI_TYPE_TAG_INT8: case GI_TYPE_TAG_UINT8: case GI_TYPE_TAG_INT16: case GI_TYPE_TAG_UINT16: case GI_TYPE_TAG_INT32: case GI_TYPE_TAG_UINT32: case GI_TYPE_TAG_INT64: case GI_TYPE_TAG_UINT64: case GI_TYPE_TAG_FLOAT: case GI_TYPE_TAG_DOUBLE: case GI_TYPE_TAG_GTYPE: case GI_TYPE_TAG_UNICHAR: break; case GI_TYPE_TAG_FILENAME: case GI_TYPE_TAG_UTF8: /* With allow-none support the string could be NULL */ if ((arg->v_string != NULL && (direction == GI_DIRECTION_IN && transfer == GI_TRANSFER_NOTHING)) || (direction == GI_DIRECTION_OUT && transfer == GI_TRANSFER_EVERYTHING)) { g_free (arg->v_string); } break; case GI_TYPE_TAG_ARRAY: { GArray *array; gsize i; if (arg->v_pointer == NULL) { return; } array = arg->v_pointer; if ( (direction == GI_DIRECTION_IN && transfer != GI_TRANSFER_EVERYTHING) || (direction == GI_DIRECTION_OUT && transfer == GI_TRANSFER_EVERYTHING)) { GITypeInfo *item_type_info; GITransfer item_transfer; item_type_info = g_type_info_get_param_type (type_info, 0); item_transfer = direction == GI_DIRECTION_IN ? GI_TRANSFER_NOTHING : GI_TRANSFER_EVERYTHING; /* Free the items */ for (i = 0; i < array->len; i++) { GIArgument *item; item = &_g_array_index (array, GIArgument, i); _pygi_argument_release (item, item_type_info, item_transfer, direction); } g_base_info_unref ( (GIBaseInfo *) item_type_info); } if ( (direction == GI_DIRECTION_IN && transfer == GI_TRANSFER_NOTHING) || (direction == GI_DIRECTION_OUT && transfer != GI_TRANSFER_NOTHING)) { g_array_free (array, TRUE); } break; } case GI_TYPE_TAG_INTERFACE: { GIBaseInfo *info; GIInfoType info_type; info = g_type_info_get_interface (type_info); info_type = g_base_info_get_type (info); switch (info_type) { case GI_INFO_TYPE_CALLBACK: /* TODO */ break; case GI_INFO_TYPE_BOXED: case GI_INFO_TYPE_STRUCT: case GI_INFO_TYPE_UNION: { GType type; if (arg->v_pointer == NULL) { return; } type = g_registered_type_info_get_g_type ( (GIRegisteredTypeInfo *) info); if (g_type_is_a (type, G_TYPE_VALUE)) { GValue *value; value = arg->v_pointer; if ( (direction == GI_DIRECTION_IN && transfer != GI_TRANSFER_EVERYTHING) || (direction == GI_DIRECTION_OUT && transfer == GI_TRANSFER_EVERYTHING)) { g_value_unset (value); } if ( (direction == GI_DIRECTION_IN && transfer == GI_TRANSFER_NOTHING) || (direction == GI_DIRECTION_OUT && transfer != GI_TRANSFER_NOTHING)) { g_slice_free (GValue, value); } } else if (g_type_is_a (type, G_TYPE_CLOSURE)) { if (direction == GI_DIRECTION_IN && transfer == GI_TRANSFER_NOTHING) { g_closure_unref (arg->v_pointer); } } else if (info_type == GI_INFO_TYPE_STRUCT && g_struct_info_is_foreign ((GIStructInfo*) info)) { if (direction == GI_DIRECTION_OUT && transfer == GI_TRANSFER_EVERYTHING) { pygi_struct_foreign_release (info, arg->v_pointer); } } else if (g_type_is_a (type, G_TYPE_BOXED)) { } else if (g_type_is_a (type, G_TYPE_POINTER) || type == G_TYPE_NONE) { g_warn_if_fail (!g_type_info_is_pointer (type_info) || transfer == GI_TRANSFER_NOTHING); } break; } case GI_INFO_TYPE_ENUM: case GI_INFO_TYPE_FLAGS: break; case GI_INFO_TYPE_INTERFACE: case GI_INFO_TYPE_OBJECT: if (arg->v_pointer == NULL) { return; } if (is_out && transfer == GI_TRANSFER_EVERYTHING) { g_object_unref (arg->v_pointer); } break; default: g_assert_not_reached(); } g_base_info_unref (info); break; } case GI_TYPE_TAG_GLIST: case GI_TYPE_TAG_GSLIST: { GSList *list; if (arg->v_pointer == NULL) { return; } list = arg->v_pointer; if ( (direction == GI_DIRECTION_IN && transfer != GI_TRANSFER_EVERYTHING) || (direction == GI_DIRECTION_OUT && transfer == GI_TRANSFER_EVERYTHING)) { GITypeInfo *item_type_info; GITransfer item_transfer; GSList *item; item_type_info = g_type_info_get_param_type (type_info, 0); g_assert (item_type_info != NULL); item_transfer = direction == GI_DIRECTION_IN ? GI_TRANSFER_NOTHING : GI_TRANSFER_EVERYTHING; /* Free the items */ for (item = list; item != NULL; item = g_slist_next (item)) { _pygi_argument_release ( (GIArgument *) &item->data, item_type_info, item_transfer, direction); } g_base_info_unref ( (GIBaseInfo *) item_type_info); } if ( (direction == GI_DIRECTION_IN && transfer == GI_TRANSFER_NOTHING) || (direction == GI_DIRECTION_OUT && transfer != GI_TRANSFER_NOTHING)) { if (type_tag == GI_TYPE_TAG_GLIST) { g_list_free ( (GList *) list); } else { /* type_tag == GI_TYPE_TAG_GSLIST */ g_slist_free (list); } } break; } case GI_TYPE_TAG_GHASH: { GHashTable *hash_table; if (arg->v_pointer == NULL) { return; } hash_table = arg->v_pointer; if (direction == GI_DIRECTION_IN && transfer != GI_TRANSFER_EVERYTHING) { /* We created the table without a destroy function, so keys and * values need to be released. */ GITypeInfo *key_type_info; GITypeInfo *value_type_info; GITransfer item_transfer; GHashTableIter hash_table_iter; gpointer key; gpointer value; key_type_info = g_type_info_get_param_type (type_info, 0); g_assert (key_type_info != NULL); value_type_info = g_type_info_get_param_type (type_info, 1); g_assert (value_type_info != NULL); if (direction == GI_DIRECTION_IN) { item_transfer = GI_TRANSFER_NOTHING; } else { item_transfer = GI_TRANSFER_EVERYTHING; } g_hash_table_iter_init (&hash_table_iter, hash_table); while (g_hash_table_iter_next (&hash_table_iter, &key, &value)) { _pygi_argument_release ( (GIArgument *) &key, key_type_info, item_transfer, direction); _pygi_argument_release ( (GIArgument *) &value, value_type_info, item_transfer, direction); } g_base_info_unref ( (GIBaseInfo *) key_type_info); g_base_info_unref ( (GIBaseInfo *) value_type_info); } else if (direction == GI_DIRECTION_OUT && transfer == GI_TRANSFER_CONTAINER) { /* Be careful to avoid keys and values being freed if the * callee gave a destroy function. */ g_hash_table_steal_all (hash_table); } if ( (direction == GI_DIRECTION_IN && transfer == GI_TRANSFER_NOTHING) || (direction == GI_DIRECTION_OUT && transfer != GI_TRANSFER_NOTHING)) { g_hash_table_unref (hash_table); } break; } case GI_TYPE_TAG_ERROR: { GError *error; if (arg->v_pointer == NULL) { return; } error = * (GError **) arg->v_pointer; if (error != NULL) { g_error_free (error); } g_slice_free (GError *, arg->v_pointer); break; } } }
static inline void empty_graph(struct pg_graph *graph) { g_hash_table_steal_all(graph->all); g_slist_free(graph->pollable); graph->pollable = NULL; }