From: Laurent Monin Date: Sun, 1 Mar 2009 23:14:19 +0000 (+0000) Subject: When g_new0() is used, drop redundant initializations to NULL, FALSE or 0, second... X-Git-Tag: v1.0.0~436 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=7fbf2e53a3a5ad667bd585d763cf0bff567d672e When g_new0() is used, drop redundant initializations to NULL, FALSE or 0, second pass. --- diff --git a/src/collect-table.c b/src/collect-table.c index 37b769ec..c764911b 100644 --- a/src/collect-table.c +++ b/src/collect-table.c @@ -2437,35 +2437,14 @@ CollectTable *collection_table_new(CollectionData *cd) gint i; ct = g_new0(CollectTable, 1); + ct->cd = cd; - ct->columns = 0; - ct->rows = 0; - - ct->selection = NULL; - ct->prev_selection = NULL; - - ct->tip_window = NULL; ct->tip_delay_id = -1; - - ct->marker_window = NULL; - ct->marker_info = NULL; - - ct->status_label = NULL; - ct->extra_label = NULL; - - ct->focus_row = 0; - ct->focus_column = 0; - ct->focus_info = NULL; - ct->show_text = options->show_icon_names; ct->sync_idle_id = -1; ct->drop_idle_id = -1; - ct->popup = NULL; - ct->drop_info = NULL; - ct->drop_list = NULL; - ct->scrolled = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(ct->scrolled), GTK_SHADOW_IN); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ct->scrolled), diff --git a/src/collect.c b/src/collect.c index 8b475526..0d3c8d61 100644 --- a/src/collect.c +++ b/src/collect.c @@ -323,23 +323,10 @@ CollectionData *collection_new(const gchar *path) cd = g_new0(CollectionData, 1); - collection_list = g_list_append(collection_list, cd); - cd->ref = 1; /* starts with a ref of 1 */ - - cd->list = NULL; cd->sort_method = SORT_NONE; - cd->thumb_loader = NULL; - cd->info_updated_func = NULL; - - cd->window_read = FALSE; - cd->window_x = 0; - cd->window_y = 0; cd->window_w = COLLECT_DEF_WIDTH; cd->window_h = COLLECT_DEF_HEIGHT; - - cd->changed = FALSE; - cd->existence = g_hash_table_new(NULL, NULL); if (path) @@ -350,8 +337,6 @@ CollectionData *collection_new(const gchar *path) } else { - cd->path = NULL; - if (untitled_counter == 0) { cd->name = g_strdup(_("Untitled")); @@ -366,6 +351,9 @@ CollectionData *collection_new(const gchar *path) file_data_register_notify_func(collection_notify_cb, cd, NOTIFY_PRIORITY_MEDIUM); + + collection_list = g_list_append(collection_list, cd); + return cd; } @@ -1183,8 +1171,6 @@ CollectWindow *collection_window_new(const gchar *path) cw = g_new0(CollectWindow, 1); - cw->close_dialog = NULL; - collection_window_list = g_list_append(collection_window_list, cw); cw->cd = collection_new(path); diff --git a/src/dupe.c b/src/dupe.c index 9252a0ed..eee5e112 100644 --- a/src/dupe.c +++ b/src/dupe.c @@ -288,18 +288,8 @@ static DupeItem *dupe_item_new(FileData *fd) di = g_new0(DupeItem, 1); di->fd = file_data_ref(fd); - - di->group = NULL; di->group_rank = 0.0; - di->simd = NULL; - di->checksum = 0; - di->md5sum = NULL; - di->width = 0; - di->height = 0; - - di->second = FALSE; - return di; } diff --git a/src/editors.c b/src/editors.c index 2632dcd3..c3cb036c 100644 --- a/src/editors.c +++ b/src/editors.c @@ -1057,8 +1057,6 @@ static gint editor_command_start(const EditorDescription *editor, const gchar *t ed->flags = flags; ed->editor = editor; ed->total = (flags & EDITOR_SINGLE_COMMAND) ? 1 : g_list_length(list); - ed->count = 0; - ed->stopping = FALSE; ed->callback = cb; ed->data = data; diff --git a/src/exif.c b/src/exif.c index 2dc8b65c..00246cf4 100644 --- a/src/exif.c +++ b/src/exif.c @@ -511,8 +511,6 @@ ExifItem *exif_item_new(ExifFormatType format, guint tag, item->tag = tag; item->marker = marker; item->elements = elements; - item->data = NULL; - item->data_len = 0; switch (format) { @@ -1228,8 +1226,6 @@ ExifData *exif_read(gchar *path, gchar *sidecar_path, GHashTable *modified_xmp) g_free(pathl); exif = g_new0(ExifData, 1); - exif->items = NULL; - exif->current = NULL; exif->path = g_strdup(path); res = exif_jpeg_parse(exif, (guchar *)f, size, ExifKnownMarkersList); diff --git a/src/filedata.c b/src/filedata.c index d4a3570e..35041758 100644 --- a/src/filedata.c +++ b/src/filedata.c @@ -346,17 +346,9 @@ static FileData *file_data_new(const gchar *path_utf8, struct stat *st, gboolean fd = g_new0(FileData, 1); - fd->path = NULL; - fd->name = NULL; - fd->collate_key_name = NULL; - fd->collate_key_name_nocase = NULL; - fd->original_path = NULL; - fd->size = st->st_size; fd->date = st->st_mtime; fd->mode = st->st_mode; - fd->thumb_pixbuf = NULL; - fd->sidecar_files = NULL; fd->ref = 1; fd->magick = 0x12345678; diff --git a/src/image-overlay.c b/src/image-overlay.c index e46e89e2..af5db8e3 100644 --- a/src/image-overlay.c +++ b/src/image-overlay.c @@ -1007,7 +1007,6 @@ static void image_osd_enable(ImageWindow *imd, OsdShowFlags show) osd->idle_id = -1; osd->timer_id = -1; osd->show = OSD_SHOW_NOTHING; - osd->histogram = NULL; osd->x = options->image_overlay.x; osd->y = options->image_overlay.y; diff --git a/src/img-view.c b/src/img-view.c index 57697413..9bc862f2 100644 --- a/src/img-view.c +++ b/src/img-view.c @@ -833,10 +833,6 @@ static ViewWindow *real_view_window_new(FileData *fd, GList *list, CollectionDat if (!fd && !list && (!cd || !info)) return NULL; vw = g_new0(ViewWindow, 1); - vw->fs = NULL; - vw->ss = NULL; - vw->list = NULL; - vw->list_pointer = NULL; vw->window = window_new(GTK_WINDOW_TOPLEVEL, "view", PIXBUF_INLINE_ICON_VIEW, NULL, NULL); diff --git a/src/pan-item.c b/src/pan-item.c index d782d24f..f976803b 100644 --- a/src/pan-item.c +++ b/src/pan-item.c @@ -450,6 +450,7 @@ PanItem *pan_item_thumb_new(PanWindow *pw, FileData *fd, gint x, gint y) PanItem *pi; pi = g_new0(PanItem, 1); + pi->type = PAN_ITEM_THUMB; pi->fd = fd; pi->x = x; @@ -457,10 +458,6 @@ PanItem *pan_item_thumb_new(PanWindow *pw, FileData *fd, gint x, gint y) pi->width = PAN_THUMB_SIZE + PAN_SHADOW_OFFSET * 2; pi->height = PAN_THUMB_SIZE + PAN_SHADOW_OFFSET * 2; - pi->pixbuf = NULL; - - pi->queued = FALSE; - pw->list = g_list_prepend(pw->list, pi); return pi; @@ -849,8 +846,6 @@ PanTextAlignment *pan_text_alignment_new(PanWindow *pw, gint x, gint y, const gc ta = g_new0(PanTextAlignment, 1); ta->pw = pw; - ta->column1 = NULL; - ta->column2 = NULL; ta->x = x; ta->y = y; ta->key = g_strdup(key); diff --git a/src/pan-view.c b/src/pan-view.c index 949c03ee..6c15dfb4 100644 --- a/src/pan-view.c +++ b/src/pan-view.c @@ -791,7 +791,6 @@ static void pan_grid_build(PanWindow *pw, gint width, gint height, gint grid_siz pg->y = j * ch / 2; pg->w = cw; pg->h = ch; - pg->list = NULL; pw->list_grid = g_list_prepend(pw->list_grid, pg); @@ -2360,11 +2359,6 @@ static void pan_window_new_real(FileData *dir_fd) pw->ignore_symlinks = TRUE; - pw->list = NULL; - pw->list_static = NULL; - pw->list_grid = NULL; - - pw->fs = NULL; pw->overlay_id = -1; pw->idle_id = -1; diff --git a/src/remote.c b/src/remote.c index 8b0a5041..07a3932f 100644 --- a/src/remote.c +++ b/src/remote.c @@ -226,15 +226,11 @@ static RemoteConnection *remote_server_open(const gchar *path) } rc = g_new0(RemoteConnection, 1); + rc->server = TRUE; rc->fd = fd; rc->path = g_strdup(path); - rc->read_func = NULL; - rc->read_data = NULL; - - rc->clients = NULL; - channel = g_io_channel_unix_new(rc->fd); g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL); diff --git a/src/search.c b/src/search.c index 05db77e0..864144ee 100644 --- a/src/search.c +++ b/src/search.c @@ -2601,10 +2601,6 @@ void search_new(FileData *dir_fd, FileData *example_file) sd->search_height = 480; sd->search_width_end = 1024; sd->search_height_end = 768; - sd->search_name = NULL; - sd->search_name_match_case = FALSE; - sd->search_comment = NULL; - sd->search_comment_match_case = FALSE; sd->search_type = SEARCH_MATCH_NONE; @@ -2616,16 +2612,13 @@ void search_new(FileData *dir_fd, FileData *example_file) sd->match_comment = SEARCH_MATCH_CONTAINS; sd->match_name_enable = TRUE; - sd->match_size_enable = FALSE; - sd->match_date_enable = FALSE; - sd->match_dimensions_enable = FALSE; - sd->match_similarity_enable = FALSE; - sd->match_keywords_enable = FALSE; - sd->match_comment_enable = FALSE; sd->search_similarity = 95; - sd->search_similarity_path = example_file ? g_strdup(example_file->path) : NULL; - sd->search_similarity_cd = NULL; + + if (example_file) + { + sd->search_similarity_path = g_strdup(example_file->path); + } sd->search_idle_id = -1; sd->update_idle_id = -1; diff --git a/src/ui_tree_edit.c b/src/ui_tree_edit.c index c2ff364a..8c3c40d4 100644 --- a/src/ui_tree_edit.c +++ b/src/ui_tree_edit.c @@ -209,7 +209,6 @@ gint tree_edit_by_path(GtkTreeView *tree, GtkTreePath *tpath, gint column, const ted = g_new0(TreeEditData, 1); ted->old_name = g_strdup(text); - ted->new_name = NULL; ted->edit_func = edit_func; ted->edit_data = data; diff --git a/src/utilops.c b/src/utilops.c index 5c824cce..e40e875a 100644 --- a/src/utilops.c +++ b/src/utilops.c @@ -341,11 +341,12 @@ static UtilityData *file_util_data_new(UtilityType type) UtilityData *ud; ud = g_new0(UtilityData, 1); + ud->type = type; ud->phase = UTILITY_PHASE_START; ud->update_idle_id = -1; ud->perform_idle_id = -1; - ud->external_command = NULL; + return ud; }