diff --git a/gnome/ChangeLog b/gnome/ChangeLog index 8e488b007..da4238201 100644 --- a/gnome/ChangeLog +++ b/gnome/ChangeLog @@ -1,3 +1,10 @@ +Wed Jan 27 03:14:46 1999 Timur Bakeyev + + * Converted memory managment to Glib - where it wasn't done. Now we + use g_new()/g_malloc()/g_strdup()/g_free() routings. copy_strings() re- + placed by g_strconcat(), and sprintf() by g_snprintf(). Some other, + minor changes. + 1999-01-26 Federico Mena Quintero * gscreen.c (panel_setup_drag_scroll): Renamed from diff --git a/gnome/gaction.c b/gnome/gaction.c index a892e40d1..1b585c5f1 100644 --- a/gnome/gaction.c +++ b/gnome/gaction.c @@ -1,9 +1,7 @@ #include #include -#include /* atoi */ -#include "fs.h" -#include "mad.h" #include "x.h" +#include "global.h" #include "dir.h" #include "command.h" #include "panel.h" diff --git a/gnome/gcmd.c b/gnome/gcmd.c index 1c79ab1d5..d39439b0d 100644 --- a/gnome/gcmd.c +++ b/gnome/gcmd.c @@ -647,7 +647,7 @@ gnome_open_files (GtkWidget *widget, WPanel *panel) /* we break out. */ break; execute (command); - free (command); + g_free (command); } #endif g_list_free (later); diff --git a/gnome/gdesktop.c b/gnome/gdesktop.c index 561c02779..091f12f2d 100644 --- a/gnome/gdesktop.c +++ b/gnome/gdesktop.c @@ -27,10 +27,10 @@ */ #include -#include "fs.h" #include #include #include +#include "global.h" #include "dialog.h" #define DIR_H_INCLUDE_HANDLE_DIRENT /* bleah */ #include "dir.h" diff --git a/gnome/gdialogs.c b/gnome/gdialogs.c index 282e10386..ebe0b9087 100644 --- a/gnome/gdialogs.c +++ b/gnome/gdialogs.c @@ -1,9 +1,9 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ /* New dialogs... */ #include -#include "util.h" #include "panel.h" #include +#include "global.h" #include "file.h" #include "filegui.h" #include "fileopctx.h" @@ -92,8 +92,7 @@ trim_file_name (FileOpContextUI *ui, gchar *path, gint length, gint cur_length) while (gdk_string_width (ui->op_source_label->style->font, path + len) > length) len ++; } - path_copy = g_malloc (sizeof (gchar [1 + 3 + strlen (path) - len])); - sprintf (path_copy, "...%s", path + len); + path_copy = g_strdup_printf ("...%s", path + len); return path_copy; } @@ -652,11 +651,11 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, char *text, char umask (i); ctx->umask_kill = i ^ 0777777; } - source_mask = strdup ("*"); + source_mask = g_strdup ("*"); orig_mask = source_mask; if (!dest_dir || !*dest_dir){ if (source_mask) - free (source_mask); + g_free (source_mask); return dest_dir; } @@ -674,7 +673,7 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, char *text, char source_mask = convert_pattern (source_mask, match_file, 1); easy_patterns = source_easy_patterns; error = re_compile_pattern (source_mask, strlen (source_mask), &ctx->rx); - free (source_mask); + g_free (source_mask); } else error = re_compile_pattern (source_mask, strlen (source_mask), &ctx->rx); @@ -682,7 +681,7 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, char *text, char g_warning ("%s\n",error); if (orig_mask) - free (orig_mask); + g_free (orig_mask); ctx->dest_mask = strrchr (dest_dir, PATH_SEP); if (ctx->dest_mask == NULL) ctx->dest_mask = dest_dir; @@ -695,14 +694,14 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, char *text, char (ctx->dive_into_subdirs && ((!only_one && !is_wildcarded (ctx->dest_mask)) || (only_one && !mc_stat (dest_dir, &buf) && S_ISDIR (buf.st_mode))))) - ctx->dest_mask = strdup ("*"); + ctx->dest_mask = g_strdup ("*"); else { - ctx->dest_mask = strdup (ctx->dest_mask); + ctx->dest_mask = g_strdup (ctx->dest_mask); *orig_mask = 0; } if (!*dest_dir){ - free (dest_dir); - dest_dir = strdup ("./"); + g_free (dest_dir); + dest_dir = g_strdup ("./"); } return dest_dir; } diff --git a/gnome/ginfo.c b/gnome/ginfo.c index bdc459b9b..817f06830 100644 --- a/gnome/ginfo.c +++ b/gnome/ginfo.c @@ -4,9 +4,8 @@ #include #include -#include #include -#include "fs.h" +#include "global.h" #include "dlg.h" #include "widget.h" #include "info.h" diff --git a/gnome/gkey.c b/gnome/gkey.c index 77fe61009..b73362ad9 100644 --- a/gnome/gkey.c +++ b/gnome/gkey.c @@ -7,7 +7,7 @@ */ #include -#include "mad.h" +#include "global.h" #include "x.h" #include "key.h" @@ -46,7 +46,7 @@ add_select_channel (int fd, select_fn callback, void *info) { struct trampoline *t; - t = xmalloc (sizeof (struct trampoline), "add_select_channel"); + t = g_new (struct trampoline, 1); t->fn = callback; t->fd = fd; t->fn_closure = info; @@ -74,7 +74,7 @@ delete_select_channel (int fd) if (tclosure){ select_list = g_list_remove (select_list, tclosure); gdk_input_remove (tclosure->tag); - free (tclosure); + g_free (tclosure); } else { fprintf (stderr, "PANIC: could not find closure for %d\n", fd); } diff --git a/gnome/glayout.c b/gnome/glayout.c index 36c8f9fb7..d47ce1d66 100644 --- a/gnome/glayout.c +++ b/gnome/glayout.c @@ -10,6 +10,7 @@ #include #include #include +#include "global.h" #include "dir.h" #include "panel.h" #include "gscreen.h" diff --git a/gnome/gmain.c b/gnome/gmain.c index e8e6548b7..622275137 100644 --- a/gnome/gmain.c +++ b/gnome/gmain.c @@ -420,7 +420,7 @@ dialog_panel_callback (struct Dlg_head *h, int id, int msg) if (current_widget == p->filter_w){ in = (WInput *) current_widget; - set_panel_filter_to (p, strdup (in->buffer)); + set_panel_filter_to (p, g_strdup (in->buffer)); return MSG_HANDLED; } diff --git a/gnome/gmenu.c b/gnome/gmenu.c index 1b65af2d9..1e99b859d 100644 --- a/gnome/gmenu.c +++ b/gnome/gmenu.c @@ -8,9 +8,8 @@ #include #include -#include +#include "global.h" #include "main.h" -#include "mad.h" #include "menu.h" #include "x.h" @@ -22,7 +21,7 @@ Menu create_menu (char *name, menu_entry *entries, int count) { Menu menu; - menu = (Menu) xmalloc (sizeof (*menu), "create_menu"); + menu = (Menu) g_malloc (sizeof (*menu)); menu->count = count; menu->max_entry_len = 0; menu->entries = entries; @@ -50,7 +49,7 @@ static void menubar_destroy (WMenu *menubar) WMenu *menubar_new (int y, int x, int cols, Menu menu [], int items) { - WMenu *menubar = (WMenu *) xmalloc (sizeof (WMenu), "menubar_new"); + WMenu *menubar = g_new (WMenu, 1); GtkWidget *g_menubar; int i, j; diff --git a/gnome/gmetadata.c b/gnome/gmetadata.c index 5be88638e..38277f809 100644 --- a/gnome/gmetadata.c +++ b/gnome/gmetadata.c @@ -6,8 +6,8 @@ */ #include -#include "fs.h" #include +#include "global.h" #include "gmetadata.h" #include #include "../vfs/vfs.h" @@ -73,7 +73,7 @@ gmeta_set_icon_pos (char *filename, int x, int y) g_return_if_fail (filename != NULL); - sprintf (buf, "%d %d", x, y); + g_snprintf (buf, sizeof (buf), "%d %d", x, y); if (gnome_metadata_set (filename, ICON_POSITION, strlen (buf) + 1, buf) != 0) g_warning ("Error setting the icon position metadata for \"%s\"", filename); diff --git a/gnome/gpageprop.c b/gnome/gpageprop.c index 1da195202..f82e70439 100644 --- a/gnome/gpageprop.c +++ b/gnome/gpageprop.c @@ -10,14 +10,12 @@ #include #include -#include /* atoi */ #include #include #include -#include "fs.h" #include "x.h" +#include "global.h" #include "gprop.h" -#include "util.h" #include "dialog.h" #include "file.h" #include "fileopctx.h" @@ -231,10 +229,10 @@ item_properties (GtkWidget *parent, char *fname, DesktopIconInfo *dii) file_op_context_destroy (ctx); if (dii) { - free (dii->filename); + g_free (dii->filename); dii->filename = full_target; } else - free (full_target); + g_free (full_target); retval |= GPROP_FILENAME; } diff --git a/gnome/gpopup.c b/gnome/gpopup.c index 511be99e4..c038bad2a 100644 --- a/gnome/gpopup.c +++ b/gnome/gpopup.c @@ -8,8 +8,8 @@ #include -#include "util.h" #include +#include "global.h" #include "panel.h" #include "cmd.h" #include "dialog.h" @@ -49,7 +49,7 @@ panel_action_open_with (GtkWidget *widget, WPanel *panel) if (!command) return; execute (command); - free (command); + g_free (command); } static void @@ -119,7 +119,7 @@ panel_action_properties (GtkWidget *widget, WPanel *panel) if (gnome_dialog_run (GNOME_DIALOG (dlg)) == 0) retval = gnome_file_property_dialog_make_changes (GNOME_FILE_PROPERTY_DIALOG (dlg)); gtk_widget_destroy (dlg); - free (full_name); + g_free (full_name); if (retval) reread_cmd (); } diff --git a/gnome/gscreen.c b/gnome/gscreen.c index 2a3a46587..1666823be 100644 --- a/gnome/gscreen.c +++ b/gnome/gscreen.c @@ -10,10 +10,8 @@ #include #include -#include /* atoi */ -#include "fs.h" -#include "mad.h" #include "x.h" +#include "global.h" #include "dir.h" #include "command.h" #include "panel.h" @@ -171,7 +169,7 @@ panel_fill_panel_list (WPanel *panel) int i, col, type_col, color; char **texts; - texts = malloc (sizeof (char *) * (items+1)); + texts = g_new (char *, items+1); gtk_clist_freeze (GTK_CLIST (cl)); gtk_clist_clear (GTK_CLIST (cl)); @@ -216,7 +214,7 @@ panel_fill_panel_list (WPanel *panel) panel->selected = selected; select_item (panel); gtk_clist_thaw (GTK_CLIST (cl)); - free (texts); + g_free (texts); } /* @@ -498,7 +496,7 @@ panel_file_list_select_row (GtkWidget *file_list, int row, int column, GdkEvent panel->dir.list [row].f.link_to_dir){ fullname = concat_dir_and_file (panel->cwd, panel->dir.list [row].fname); new_panel_at (fullname); - free (fullname); + g_free (fullname); } } break; @@ -675,7 +673,7 @@ panel_build_selected_file_list (WPanel *panel, int *file_list_len) total_len += (filelen + cwdlen + panel->dir.list [i].fnamelen + seplen); total_len++; - data = copy = xmalloc (total_len+1, "build_selected_file_list"); + data = copy = g_malloc (total_len+1); for (i = 0; i < panel->count; i++) if (panel->dir.list [i].f.marked){ strcpy (copy, "file:"); @@ -694,7 +692,7 @@ panel_build_selected_file_list (WPanel *panel, int *file_list_len) fullname = concat_dir_and_file (panel->cwd, panel->dir.list [panel->selected].fname); uri = copy_strings ("file:", fullname, NULL); - free (fullname); + g_free (fullname); *file_list_len = strlen (uri) + 1; return uri; @@ -788,7 +786,7 @@ panel_icon_list_drag_data_received (GtkWidget *widget, } reload = gdnd_drop_on_directory (context, selection_data, dir); - free (dir); + g_free (dir); if (reload){ update_one_panel_widget (panel, 0, UP_KEEPSEL); @@ -829,7 +827,7 @@ panel_clist_drag_data_received (GtkWidget *widget, } gdnd_drop_on_directory (context, selection_data, dir); - free (dir); + g_free (dir); update_one_panel_widget (panel, 0, UP_KEEPSEL); panel_update_contents (panel); @@ -1325,7 +1323,7 @@ panel_icon_list_select_icon (GtkWidget *widget, int index, GdkEvent *event, WPan panel->dir.list [index].f.link_to_dir){ fullname = concat_dir_and_file (panel->cwd, panel->dir.list [index].fname); new_panel_at (fullname); - free (fullname); + g_free (fullname); } } break; @@ -1356,8 +1354,8 @@ panel_icon_renamed (GtkWidget *widget, int index, char *dest, WPanel *panel) source = panel->dir.list [index].fname; if (mc_rename (source, dest) == 0){ - free (panel->dir.list [index].fname); - panel->dir.list [index].fname = strdup (dest); + g_free (panel->dir.list [index].fname); + panel->dir.list [index].fname = g_strdup (dest); return TRUE; } else return FALSE; @@ -1714,7 +1712,7 @@ display_mini_info (WPanel *panel) link = concat_dir_and_file (panel->cwd, panel->dir.list [panel->selected].fname); len = mc_readlink (link, link_target, MC_MAXPATHLEN); - free (link); + g_free (link); if (len > 0){ link_target [len] = 0; @@ -1722,7 +1720,7 @@ display_mini_info (WPanel *panel) /* str = copy_strings ("-> ", link_target, NULL); */ gnome_appbar_pop (bar); gnome_appbar_push (bar, " "); - /*free (str); */ + /* g_free (str); */ } else { gnome_appbar_pop (bar); gnome_appbar_push (bar, _("")); @@ -1734,12 +1732,12 @@ display_mini_info (WPanel *panel) int len = panel->estimated_total; char *buffer; - buffer = xmalloc (len + 2, "display_mini_info"); + buffer = g_malloc (len + 2); format_file (buffer, panel, panel->selected, panel->estimated_total-2, 0, 1); buffer [len] = 0; gnome_appbar_pop (bar); gnome_appbar_push (bar, buffer); - free (buffer); + g_free (buffer); } if (panel->list_type == list_icons){ if (panel->marked == 0){ @@ -2541,14 +2539,14 @@ panel_update_cols (Widget *panel, int frame_size) char * get_nth_panel_name (int num) { - static char buffer [20]; + static char buffer [BUF_TINY]; if (!num) return "New Left Panel"; else if (num == 1) return "New Right Panel"; else { - sprintf (buffer, "%ith Panel", num); + g_snprintf (buffer, sizeof (buffer), "%ith Panel", num); return buffer; } } @@ -2561,7 +2559,7 @@ load_hint (void) if ((hint = get_random_hint ())){ if (*hint) set_hintbar (hint); - free (hint); + g_free (hint); } else set_hintbar ("The GNOME File Manager " VERSION); diff --git a/gnome/gtkdtree.c b/gnome/gtkdtree.c index d5ab40dc1..b376cdaee 100644 --- a/gnome/gtkdtree.c +++ b/gnome/gtkdtree.c @@ -7,15 +7,14 @@ * */ #include -#include "util.h" #include "treestore.h" #include #include "gtkdtree.h" - #include #include #include #include +#include "global.h" #include "dir-open.xpm" #include "dir-close.xpm" diff --git a/gnome/gtools.c b/gnome/gtools.c index 91113aa2b..a17467238 100644 --- a/gnome/gtools.c +++ b/gnome/gtools.c @@ -5,10 +5,10 @@ */ #include #include "myslang.h" -#include "util.h" #include #include #include +#include "global.h" #include "gconf.h" #include "dlg.h" #undef HAVE_LIBGPM diff --git a/gnome/gutil.c b/gnome/gutil.c index 69caa625c..73f4a6909 100644 --- a/gnome/gutil.c +++ b/gnome/gutil.c @@ -20,7 +20,6 @@ #include #include -#include #include #ifdef HAVE_UNISTD_H #include @@ -47,7 +46,7 @@ #include #include #include -#include "util.h" +#include "global.h" int my_system_get_child_pid (int flags, const char *shell, const char *command, pid_t *pid) { diff --git a/gnome/gview.c b/gnome/gview.c index 8a43cb535..bb046c806 100644 --- a/gnome/gview.c +++ b/gnome/gview.c @@ -90,7 +90,7 @@ view_percent (WView *view, int p, int w) p / (view->s.st_size / 100) : p * 100 / view->s.st_size); - sprintf (buffer, "%3d%%", percent); + g_snprintf (buffer, sizeof (buffer), "%3d%%", percent); if (strcmp (buffer, GTK_LABEL (view->gtk_percent)->label)) gtk_label_set (GTK_LABEL (view->gtk_percent), buffer); @@ -116,13 +116,13 @@ view_status (WView *view) char buffer [80]; if (view->hex_mode) - sprintf (buffer, _("Offset 0x%08x"), view->edit_cursor); + g_snprintf (buffer, sizeof (buffer), _("Offset 0x%08x"), view->edit_cursor); else - sprintf (buffer, _("Col %d"), -view->start_col); + g_snprintf (buffer, sizeof (buffer), _("Col %d"), -view->start_col); if (strcmp (buffer, GTK_LABEL (view->gtk_offset)->label)) gtk_label_set (GTK_LABEL (view->gtk_offset), buffer); - sprintf (buffer, _("%s bytes"), size_trunc (view->s.st_size)); + g_snprintf (buffer, sizeof (buffer), _("%s bytes"), size_trunc (view->s.st_size)); if (strcmp (buffer, GTK_LABEL (view->gtk_bytes)->label)) gtk_label_set (GTK_LABEL (view->gtk_bytes), buffer); diff --git a/gnome/gwidget.c b/gnome/gwidget.c index 0295c7f41..941623647 100644 --- a/gnome/gwidget.c +++ b/gnome/gwidget.c @@ -87,19 +87,19 @@ stock_from_text (char *text) { char *stock; - if (strcasecmp (text, _("ok")) == 0) + if ( g_strcasecmp (text, _("ok")) == 0) stock = GNOME_STOCK_BUTTON_OK; - else if (strcasecmp (text, _("cancel")) == 0) + else if ( g_strcasecmp (text, _("cancel")) == 0) stock = GNOME_STOCK_BUTTON_CANCEL; - else if (strcasecmp (text, _("help")) == 0) + else if ( g_strcasecmp (text, _("help")) == 0) stock = GNOME_STOCK_BUTTON_HELP; - else if (strcasecmp (text, _("yes")) == 0) + else if ( g_strcasecmp (text, _("yes")) == 0) stock = GNOME_STOCK_BUTTON_YES; - else if (strcasecmp (text, _("no")) == 0) + else if ( g_strcasecmp (text, _("no")) == 0) stock = GNOME_STOCK_BUTTON_NO; - else if (strcasecmp (text, _("exit")) == 0) + else if ( g_strcasecmp (text, _("exit")) == 0) stock = GNOME_STOCK_BUTTON_CLOSE; - else if (strcasecmp (text, _("abort")) == 0) + else if ( g_strcasecmp (text, _("abort")) == 0) stock = GNOME_STOCK_BUTTON_CANCEL; else stock = 0; @@ -551,7 +551,7 @@ x_create_buttonbar (Dlg_head *h, widget_data parent, WButtonBar *bb) char buffer [40]; GtkButton *b; - sprintf (buffer, "F%d %s", i+1, bb->labels [i].text ? bb->labels [i].text : " "); + g_snprintf (buffer, sizeof (buffer), "F%d %s", i+1, bb->labels [i].text ? bb->labels [i].text : " "); b = (GtkButton *) gtk_button_new_with_label (buffer); gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (buttonbar_clicked), bb); diff --git a/gnome/make-thumb.c b/gnome/make-thumb.c index faec2a5de..0a02b9c8b 100644 --- a/gnome/make-thumb.c +++ b/gnome/make-thumb.c @@ -40,7 +40,7 @@ put_in_metadata (char *dest, char *png_file) exit (1); } - buffer = malloc (buf.st_size); + buffer = g_malloc (buf.st_size); if (buffer == NULL){ printf ("No memory\n"); exit (1); @@ -53,7 +53,7 @@ put_in_metadata (char *dest, char *png_file) gnome_metadata_set (dest, "icon-inline-png", buf.st_size, buffer); - free (buffer); + g_free (buffer); } static void diff --git a/gnome/olddnd.c b/gnome/olddnd.c index 86179e0c1..6b2689abe 100644 --- a/gnome/olddnd.c +++ b/gnome/olddnd.c @@ -100,7 +100,7 @@ panel_make_local_copies_and_transfer (GtkWidget *widget, GdkEventDragRequest *ev int j, total_len; /* First assemble all of the filenames */ - local_names_array = malloc (sizeof (char *) * panel->marked); + local_names_array = g_new (char *, panel->marked); total_len = j = 0; for (i = 0; i < panel->count; i++){ char *filename; @@ -112,10 +112,10 @@ panel_make_local_copies_and_transfer (GtkWidget *widget, GdkEventDragRequest *ev localname = mc_getlocalcopy (filename); total_len += strlen (localname) + 1; local_names_array [j++] = localname; - free (filename); + g_free (filename); } *len = total_len; - *data = p = malloc (total_len); + *data = p = g_malloc (total_len); for (i = 0; i < j; i++){ strcpy (p, local_names_array [i]); g_free (local_names_array [i]); @@ -124,7 +124,7 @@ panel_make_local_copies_and_transfer (GtkWidget *widget, GdkEventDragRequest *ev } else { filename = concat_dir_and_file (panel->cwd, panel->dir.list [panel->selected].fname); localname = mc_getlocalcopy (filename); - free (filename); + g_free (filename); *data = localname; *len = strlen (localname + 1); } @@ -166,7 +166,7 @@ panel_clist_drag_request (GtkWidget *widget, GdkEventDragRequest *event, WPanel gdk_window_dnd_data_set ((GdkWindow *)clist_window, (GdkEvent *) event, data, len); else gdk_window_dnd_data_set ((GdkWindow *)clist_areaw, (GdkEvent *) event, data, len); - free (data); + g_free (data); } } @@ -199,7 +199,7 @@ panel_clist_drop_data_available (GtkWidget *widget, GdkEventDropDataAvailable *d #endif if (drop_dir != panel->cwd) - free (drop_dir); + g_free (drop_dir); update_one_panel_widget (panel, 0, UP_KEEPSEL); panel_update_contents (panel); @@ -264,7 +264,7 @@ panel_icon_list_drag_request (GtkWidget *widget, GdkEventDragRequest *event, WPa if (len && data){ gdk_window_dnd_data_set (widget->window, (GdkEvent *) event, data, len); - free (data); + g_free (data); } } @@ -300,7 +300,7 @@ panel_icon_list_drop_data_available (GtkWidget *widget, GdkEventDropDataAvailabl #endif if (drop_dir != panel->cwd) - free (drop_dir); + g_free (drop_dir); update_one_panel_widget (panel, 0, UP_KEEPSEL); panel_update_contents (panel); @@ -369,7 +369,7 @@ init_spot_list (void) x_spots = gdk_screen_width () / SNAP_X; y_spots = gdk_screen_height () / SNAP_Y; size = (x_spots * y_spots) / 8; - spot_array = xmalloc (size+1, "spot_array"); + spot_array = g_malloc (size+1); memset (spot_array, 0, size); } @@ -529,7 +529,7 @@ get_desktop_icon (char *pathname) /* Try the GNOME icon */ if (fname){ full_fname = gnome_unconditional_pixmap_file (fname); - free (fname); + g_free (fname); if (exist_file (full_fname)) return full_fname; g_free (full_fname); @@ -541,7 +541,7 @@ get_desktop_icon (char *pathname) if (exist_file (full_fname)) return full_fname; - free (full_fname); + g_free (full_fname); } return gnome_unconditional_pixmap_file ("launcher-program.png"); @@ -784,7 +784,7 @@ perform_drop_manually (GList *names, GdkDragAction action, char *dest) copy_file_file (p, tmpf, 1); } } while (res != 0); - free (tmpf); + g_free (tmpf); break; case GDK_ACTION_MOVE: @@ -802,7 +802,7 @@ perform_drop_manually (GList *names, GdkDragAction action, char *dest) move_file_file (p, tmpf); } } while (res != 0); - free (tmpf); + g_free (tmpf); break; default: @@ -826,7 +826,7 @@ do_symlinks (GList *names, char *dest) else mc_symlink (name, full_dest_name); - free (full_dest_name); + g_free (full_dest_name); } } @@ -850,7 +850,7 @@ drops_from_event (GdkEventDropDataAvailable *event, int *argc) } /* Create the exec vector with all of the filenames */ - argv = (char **) xmalloc (sizeof (char *) * arguments + 1, "arguments"); + argv = g_new (char *, arguments + 1); count = event->data_numbytes; p = event->data; i = 0; @@ -932,7 +932,7 @@ desktop_release_desktop_icon_t (desktop_icon_t *di, int destroy_dentry) else gnome_desktop_entry_free (di->dentry); } else { - free (di->pathname); + g_free (di->pathname); di->pathname = 0; } @@ -940,7 +940,7 @@ desktop_release_desktop_icon_t (desktop_icon_t *di, int destroy_dentry) gtk_widget_destroy (di->widget); di->widget = 0; } - free (di); + g_free (di); } static int @@ -956,7 +956,7 @@ remove_directory (char *path) buffer = copy_strings (_("Do you want to delete "), path, "?", NULL); i = query_dialog (_("Delete"), buffer, D_ERROR, 2, _("&Yes"), _("&No")); - free (buffer); + g_free (buffer); if (i != 0) return 0; } @@ -1020,14 +1020,14 @@ drop_on_launch_entry (GtkWidget *widget, GdkEventDropDataAvailable *event, deskt r = regex_command (di->pathname, "Drop", drops, 0); if (r && strcmp (r, "Success") == 0){ - free (drops); + g_free (drops); return; } if (is_exe (s.st_mode)) gnome_desktop_entry_launch_with_args (di->dentry, drop_count, drops); - free (drops); + g_free (drops); } static void @@ -1040,7 +1040,7 @@ url_dropped (GtkWidget *widget, GdkEventDropDataAvailable *event, desktop_icon_t /* if DI is set to zero, then it is a drop on the root window */ if (di) - is_directory = strcasecmp (di->dentry->type, "directory") == 0; + is_directory = g_strcasecmp (di->dentry->type, "directory") == 0; else { char *drop_location; @@ -1121,9 +1121,9 @@ desktop_icon_configure_position (desktop_icon_t *di, int x, int y) if (di->dentry){ char buffer [40]; - sprintf (buffer, "%d,%d", x, y); + g_snprintf (buffer, sizeof (buffer), "%d,%d", x, y); if (di->dentry->geometry) - g_free (di->dentry->geometry); + g_free (di->dentry->geometry); di->dentry->geometry = g_strdup (buffer); gnome_desktop_entry_save (di->dentry); } @@ -1217,7 +1217,7 @@ desktop_icon_drag_start (GtkWidget *widget, GdkEvent *event, desktop_icon_t *di) destroy_shaped_dnd_windows (); if (di->dentry) - fname = strdup (di->dentry->icon); + fname = g_strdup (di->dentry->icon); else fname = get_desktop_icon (di->pathname); @@ -1233,7 +1233,7 @@ desktop_icon_drag_start (GtkWidget *widget, GdkEvent *event, desktop_icon_t *di) gtk_widget_show (root_drag_not_ok_window); gtk_widget_show (root_drag_ok_window); } - free (fname); + g_free (fname); } } @@ -1440,7 +1440,7 @@ desktop_load_from_dentry (GnomeDesktopEntry *dentry) if (!dicon) return; - di = xmalloc (sizeof (desktop_icon_t), "desktop_load_entry"); + di = g_new (desktop_icon_t, 1); di->dentry = dentry; di->widget = dicon; di->pathname = dentry->location; @@ -1476,7 +1476,7 @@ desktop_setup_geometry_from_point (GnomeDesktopEntry *dentry, GdkPoint **point) { char buffer [40]; - sprintf (buffer, "%d,%d", (*point)->x, (*point)->y); + g_snprintf (buffer, sizeof (buffer), "%d,%d", (*point)->x, (*point)->y); dentry->geometry = g_strdup (buffer); *point = NULL; } @@ -1490,10 +1490,10 @@ desktop_create_directory_entry (char *dentry_path, char *pathname, char *short_n { GnomeDesktopEntry *dentry; - dentry = xmalloc (sizeof (GnomeDesktopEntry), "dcde"); + dentry = g_new (GnomeDesktopEntry, 1); memset (dentry, 0, sizeof (GnomeDesktopEntry)); dentry->name = g_strdup (short_name); - dentry->exec = (char **) malloc (2 * sizeof (char *)); + dentry->exec = g_new (char *, 2); dentry->exec[0] = g_strdup (pathname); dentry->exec[1] = NULL; dentry->exec_length = 1; @@ -1535,7 +1535,7 @@ desktop_file_exec (GtkWidget *widget, GdkEventButton *event, desktop_icon_t *di) _(" Do you really want to execute? "), 0, 2, _("&Yes"), _("&No")) == 0)) execute (tmp); - free (tmp); + g_free (tmp); } else { char *result, *command; @@ -1547,7 +1547,7 @@ desktop_file_exec (GtkWidget *widget, GdkEventButton *event, desktop_icon_t *di) di->pathname); if (command){ execute (command); - free (command); + g_free (command); } } } @@ -1572,11 +1572,11 @@ desktop_create_launch_entry (char *desktop_file, char *pathname, char *short_nam struct stat s; stat (pathname, &s); - dentry = xmalloc (sizeof (GnomeDesktopEntry), "launch_entry"); + dentry = g_new (GnomeDesktopEntry, 1); memset (dentry, 0, sizeof (GnomeDesktopEntry)); dentry->name = g_strdup (short_name); - dentry->exec = (char **) malloc (2 * sizeof (char *)); + dentry->exec = g_new (char *, 2); dentry->exec[0] = g_strdup (pathname); dentry->exec[1] = NULL; dentry->exec_length = 1; @@ -1595,10 +1595,10 @@ desktop_create_launch_entry (char *desktop_file, char *pathname, char *short_nam if (!dicon) return; - di = xmalloc (sizeof (desktop_icon_t), "dcle"); + di = g_new (desktop_icon_t, 1); di->dentry = NULL; di->widget = dicon; - di->pathname = strdup (pathname); + di->pathname = g_strdup (pathname); desktop_icon_set_position (di); desktop_icon_make_draggable (di); @@ -1647,7 +1647,7 @@ desktop_setup_icon (char *filename, char *full_pathname, GdkPoint **desired_posi else desktop_create_directory_entry (dir_full, full_pathname, filename, desired_position); } - free (dir_full); + g_free (dir_full); } else { if (strstr (filename, ".desktop")){ if (!desktop_pathname_loaded (full_pathname)) @@ -1658,7 +1658,7 @@ desktop_setup_icon (char *filename, char *full_pathname, GdkPoint **desired_posi desktop_version = copy_strings (full_pathname, ".desktop", NULL); if (!exist_file (desktop_version) && !desktop_pathname_loaded (full_pathname)) desktop_create_launch_entry (desktop_version, full_pathname, filename, desired_position); - free (desktop_version); + g_free (desktop_version); } } } @@ -1696,7 +1696,7 @@ desktop_reload (char *desktop_dir, GdkPoint *drop_position) full = concat_dir_and_file (desktop_dir, dent->d_name); desktop_setup_icon (dent->d_name, full, &drop_position); - free (full); + g_free (full); } mc_closedir (dir); @@ -1737,8 +1737,8 @@ desktop_setup_default (char *desktop_dir) mkdir (desktop_dir, 0777); desktop_create_directory_entry (desktop_dir_home_link, "~", "Home directory", NULL); - free (desktop_dir_home_link); - free (mc_desktop_dir); + g_free (desktop_dir_home_link); + g_free (mc_desktop_dir); } /*