Commit 82ce59cd authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Remove unnecessary NULL checks before g_free(). (#369666, Morten Welinder,

2007-03-09  Matthias Clasen <mclasen@redhat.com>

        * Everywhere: Remove unnecessary NULL checks before
        g_free().  (#369666, Morten Welinder, Djihed Afifi)

        * configure.in: Check for ftw.h



svn path=/trunk/; revision=17444
parent a1e45544
2007-03-09 Matthias Clasen <mclasen@redhat.com>
* Everywhere: Remove unnecessary NULL checks before
g_free(). (#369666, Morten Welinder, Djihed Afifi)
* configure.in: Check for ftw.h
2007-03-09 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilesystemwin32.c (get_icon_path): Remove
......
......@@ -564,6 +564,7 @@ LIBS=$gtk_save_LIBS
AC_CHECK_HEADERS(pwd.h, AC_DEFINE(HAVE_PWD_H))
AC_CHECK_HEADERS(sys/time.h, AC_DEFINE(HAVE_SYS_TIME_H))
AC_CHECK_HEADERS(unistd.h, AC_DEFINE(HAVE_UNISTD_H))
AC_CHECK_HEADERS(ftw.h, AC_DEFINE(HAVE_FTW_H))
saved_cflags="$CFLAGS"
saved_ldflags="$LDFLAGS"
......
......@@ -691,8 +691,7 @@ static gboolean gdk_pixbuf__bmp_image_stop_load(gpointer data, GError **error)
g_return_val_if_fail(context != NULL, TRUE);
if (context->Colormap != NULL)
g_free(context->Colormap);
g_free(context->Colormap);
if (context->pixbuf)
g_object_unref(context->pixbuf);
......
......@@ -176,11 +176,9 @@ static gboolean gdk_pixbuf__ico_image_load_increment(gpointer data,
static void
context_free (struct ico_progressive_state *context)
{
if (context->LineBuf != NULL)
g_free (context->LineBuf);
g_free (context->LineBuf);
context->LineBuf = NULL;
if (context->HeaderBuf != NULL)
g_free (context->HeaderBuf);
g_free (context->HeaderBuf);
if (context->pixbuf)
g_object_unref (context->pixbuf);
......
......@@ -103,16 +103,12 @@ fill_pcx_context(struct pcx_context *context)
static void
free_pcx_context(struct pcx_context *context, gboolean unref_pixbuf)
{
if(context->header)
g_free(context->header);
if(context->buf)
g_free(context->buf);
g_free(context->header);
g_free(context->buf);
if(unref_pixbuf && context->pixbuf)
g_object_unref(context->pixbuf);
if(context->line)
g_free(context->line);
if(context->p_data)
g_free(context->p_data);
g_free(context->line);
g_free(context->p_data);
g_free(context);
}
......
......@@ -283,8 +283,7 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error)
}
if (setjmp (png_ptr->jmpbuf)) {
if (rows)
g_free (rows);
g_free (rows);
if (pixbuf)
g_object_unref (pixbuf);
......
......@@ -281,10 +281,8 @@ gdk_pixbuf__ras_image_stop_load(gpointer data, GError **error)
g_return_val_if_fail(context != NULL, TRUE);
if (context->LineBuf != NULL)
g_free(context->LineBuf);
if (context->HeaderBuf != NULL)
g_free(context->HeaderBuf);
g_free(context->LineBuf);
g_free(context->HeaderBuf);
if (context->pixbuf)
g_object_unref(context->pixbuf);
......
......@@ -228,8 +228,7 @@ static IOBuffer *io_buffer_free_segment(IOBuffer *buffer,
static void io_buffer_free(IOBuffer *buffer)
{
g_return_if_fail(buffer != NULL);
if (buffer->data)
g_free(buffer->data);
g_free(buffer->data);
g_free(buffer);
}
......@@ -943,11 +942,9 @@ static gboolean gdk_pixbuf__tga_stop_load(gpointer data, GError **err)
ctx->pbuf->width, ctx->pbuf->height,
ctx->udata);
}
if (ctx->hdr)
g_free (ctx->hdr);
g_free (ctx->hdr);
if (ctx->cmap) {
if (ctx->cmap->cols)
g_free (ctx->cmap->cols);
g_free (ctx->cmap->cols);
g_free (ctx->cmap);
}
if (ctx->pbuf)
......
......@@ -692,8 +692,7 @@ gdk_get_program_class (void)
void
gdk_set_program_class (const char *program_class)
{
if (gdk_progclass)
g_free (gdk_progclass);
g_free (gdk_progclass);
gdk_progclass = g_strdup (program_class);
}
......
......@@ -465,8 +465,7 @@ gdk_event_free (GdkEvent *event)
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
if (event->button.axes)
g_free (event->button.axes);
g_free (event->button.axes);
break;
case GDK_EXPOSE:
......@@ -475,8 +474,7 @@ gdk_event_free (GdkEvent *event)
break;
case GDK_MOTION_NOTIFY:
if (event->motion.axes)
g_free (event->motion.axes);
g_free (event->motion.axes);
break;
case GDK_SETTING:
......
......@@ -526,8 +526,7 @@ gdk_rgb_free_info (GdkRgbInfo *image_info)
{
GSList *tmp_list;
if (image_info->stage_buf)
g_free (image_info->stage_buf);
g_free (image_info->stage_buf);
if (image_info->gray_cmap)
gdk_rgb_cmap_free (image_info->gray_cmap);
......@@ -535,11 +534,9 @@ gdk_rgb_free_info (GdkRgbInfo *image_info)
if (image_info->own_gc)
g_object_unref (image_info->own_gc);
if (image_info->colorcube)
g_free (image_info->colorcube);
g_free (image_info->colorcube);
if (image_info->colorcube_d)
g_free (image_info->colorcube_d);
g_free (image_info->colorcube_d);
tmp_list = image_info->cmap_info_list;
while (tmp_list)
......
......@@ -2130,8 +2130,7 @@ gdk_window_draw_trapezoids (GdkDrawable *drawable,
else
gdk_draw_trapezoids (private->impl, gc, trapezoids, n_trapezoids);
if (new_trapezoids)
g_free (new_trapezoids);
g_free (new_trapezoids);
RESTORE_GC (gc);
}
......
......@@ -835,8 +835,7 @@ miComputeWideEllipse(int lw, miArc *parc, gboolean *mustFree)
spdata = lruent->spdata;
if (!spdata || spdata->k != k)
{
if (spdata)
g_free(spdata);
g_free(spdata);
spdata = (miArcSpanData *)g_malloc(sizeof(miArcSpanData) +
sizeof(miArcSpan) * (k + 2));
lruent->spdata = spdata;
......
......@@ -195,7 +195,7 @@ void miAppendSpans(SpanGroup *spanGroup, SpanGroup *otherGroup, Spans *spans)
void miFreeSpanGroup(SpanGroup *spanGroup)
{
if (spanGroup->group != NULL) g_free(spanGroup->group);
g_free(spanGroup->group);
}
static void QuickSortSpansX(register GdkSpan points[], register int numSpans)
......@@ -368,10 +368,8 @@ void miFillUniqueSpanGroup(GdkDrawable *pDraw, GdkGC *pGC, SpanGroup *spanGroup)
if (!yspans || !ysizes)
{
if (yspans)
g_free (yspans);
if (ysizes)
g_free (ysizes);
g_free (yspans);
g_free (ysizes);
miDisposeSpanGroup (spanGroup);
return;
}
......@@ -438,8 +436,7 @@ void miFillUniqueSpanGroup(GdkDrawable *pDraw, GdkGC *pGC, SpanGroup *spanGroup)
}
g_free (yspans);
g_free (ysizes);
if (points)
g_free (points);
g_free (points);
return;
}
count = 0;
......
......@@ -251,8 +251,7 @@ _gdk_windowing_gc_copy (GdkGC *dst_gc,
dst_quartz_gc->cap_style = src_quartz_gc->cap_style;
dst_quartz_gc->join_style = src_quartz_gc->join_style;
if (dst_quartz_gc->dash_lengths)
g_free (dst_quartz_gc->dash_lengths);
g_free (dst_quartz_gc->dash_lengths);
dst_quartz_gc->dash_lengths = g_memdup (src_quartz_gc->dash_lengths,
sizeof (float) * src_quartz_gc->dash_count);
dst_quartz_gc->dash_count = src_quartz_gc->dash_count;
......
......@@ -107,8 +107,7 @@ gdk_gc_win32_finalize (GObject *object)
if (win32_gc->values_mask & GDK_GC_FONT)
gdk_font_unref (win32_gc->font);
if (win32_gc->pen_dashes)
g_free (win32_gc->pen_dashes);
g_free (win32_gc->pen_dashes);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
......@@ -618,8 +617,7 @@ _gdk_windowing_gc_copy (GdkGC *dst_gc,
if (dst_win32_gc->font != NULL)
gdk_font_unref (dst_win32_gc->font);
if (dst_win32_gc->pen_dashes)
g_free (dst_win32_gc->pen_dashes);
g_free (dst_win32_gc->pen_dashes);
dst_win32_gc->hcliprgn = src_win32_gc->hcliprgn;
if (dst_win32_gc->hcliprgn)
......
......@@ -240,8 +240,7 @@ gdk_property_change (GdkWindow *window,
WIN32_API_FAILED ("GlobalAlloc");
if (!CloseClipboard ())
WIN32_API_FAILED ("CloseClipboard");
if (buf != NULL)
g_free (buf);
g_free (buf);
return;
}
......
......@@ -247,12 +247,9 @@ gdk_input_device_new (GdkDisplay *display,
error:
g_free (gdkdev->info.name);
if (gdkdev->axes)
g_free (gdkdev->axes);
if (gdkdev->info.keys)
g_free (gdkdev->info.keys);
if (gdkdev->info.axes)
g_free (gdkdev->info.axes);
g_free (gdkdev->axes);
g_free (gdkdev->info.keys);
g_free (gdkdev->info.axes);
g_object_unref (gdkdev);
return NULL;
......
......@@ -639,8 +639,7 @@ init_xinerama_support (GdkScreen * screen)
int opcode, firstevent, firsterror;
#endif
if (screen_x11->monitors)
g_free (screen_x11->monitors);
g_free (screen_x11->monitors);
#ifdef HAVE_XINERAMA
if (XQueryExtension (GDK_SCREEN_XDISPLAY (screen), "XINERAMA",
......
......@@ -194,8 +194,7 @@ gdk_window_impl_x11_finalize (GObject *object)
_gdk_xid_table_remove (display, window_impl->toplevel->focus_window);
}
if (window_impl->toplevel)
g_free (window_impl->toplevel);
g_free (window_impl->toplevel);
if (window_impl->cursor)
gdk_cursor_unref (window_impl->cursor);
......
......@@ -809,8 +809,8 @@ gtk_about_dialog_set_version (GtkAboutDialog *about,
priv = (GtkAboutDialogPrivate *)about->private_data;
tmp = priv->version;
priv->version = version ? g_strdup (version) : NULL;
g_free (tmp);
priv->version = g_strdup (version);
g_free (tmp);
update_name_version (about);
......@@ -862,7 +862,7 @@ gtk_about_dialog_set_copyright (GtkAboutDialog *about,
priv = (GtkAboutDialogPrivate *)about->private_data;
tmp = priv->copyright;
priv->copyright = copyright ? g_strdup (copyright) : NULL;
priv->copyright = g_strdup (copyright);
g_free (tmp);
if (priv->copyright != NULL)
......
......@@ -336,8 +336,7 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object,
priv->stock_size = g_value_get_uint (value);
break;
case PROP_STOCK_DETAIL:
if (priv->stock_detail)
g_free (priv->stock_detail);
g_free (priv->stock_detail);
priv->stock_detail = g_value_dup_string (value);
break;
case PROP_ICON_NAME:
......
......@@ -592,8 +592,7 @@ gtk_cell_renderer_text_finalize (GObject *object)
pango_font_description_free (celltext->font);
if (celltext->text)
g_free (celltext->text);
g_free (celltext->text);
if (celltext->extra_attrs)
pango_attr_list_unref (celltext->extra_attrs);
......@@ -1009,8 +1008,7 @@ gtk_cell_renderer_text_set_property (GObject *object,
switch (param_id)
{
case PROP_TEXT:
if (celltext->text)
g_free (celltext->text);
g_free (celltext->text);
if (priv->markup_set)
{
......@@ -1054,8 +1052,7 @@ gtk_cell_renderer_text_set_property (GObject *object,
return;
}
if (celltext->text)
g_free (celltext->text);
g_free (celltext->text);
if (celltext->extra_attrs)
pango_attr_list_unref (celltext->extra_attrs);
......
......@@ -2525,8 +2525,7 @@ set_cell_contents (GtkCList *clist,
!GTK_CLIST_AUTO_RESIZE_BLOCKED (clist))
column_auto_resize (clist, clist_row, column, requisition.width);
if (old_text)
g_free (old_text);
g_free (old_text);
if (old_pixmap)
gdk_pixmap_unref (old_pixmap);
if (old_mask)
......@@ -6324,8 +6323,7 @@ column_title_new (GtkCList *clist,
gint column,
const gchar *title)
{
if (clist->column[column].title)
g_free (clist->column[column].title);
g_free (clist->column[column].title);
clist->column[column].title = g_strdup (title);
}
......@@ -6336,8 +6334,7 @@ columns_delete (GtkCList *clist)
gint i;
for (i = 0; i < clist->columns; i++)
if (clist->column[i].title)
g_free (clist->column[i].title);
g_free (clist->column[i].title);
g_free (clist->column);
}
......
......@@ -232,8 +232,7 @@ gtk_combo_entry_key_press (GtkEntry * entry, GdkEventKey * event, GtkCombo * com
gtk_editable_set_position (editable, pos);
}
if (nprefix)
g_free (nprefix);
g_free (nprefix);
g_free (prefix);
g_completion_free (cmpl);
......
......@@ -3024,8 +3024,7 @@ set_cell_contents (GtkCList *clist,
!GTK_CLIST_AUTO_RESIZE_BLOCKED (clist))
column_auto_resize (clist, clist_row, column, requisition.width);
if (old_text)
g_free (old_text);
g_free (old_text);
if (old_pixmap)
gdk_pixmap_unref (old_pixmap);
if (old_mask)
......
......@@ -350,8 +350,7 @@ gtk_curve_interpolate (GtkCurve *c, gint width, gint height)
if (c->num_points != width)
{
c->num_points = width;
if (c->point)
g_free (c->point);
g_free (c->point);
c->point = g_malloc (c->num_points * sizeof (c->point[0]));
}
......@@ -687,8 +686,7 @@ gtk_curve_set_curve_type (GtkCurve *c, GtkCurveType new_type)
}
else if (c->curve_type == GTK_CURVE_TYPE_FREE)
{
if (c->ctlpoint)
g_free (c->ctlpoint);
g_free (c->ctlpoint);
c->num_ctlpoints = 9;
c->ctlpoint = g_malloc (c->num_ctlpoints * sizeof (*c->ctlpoint));
......@@ -746,8 +744,7 @@ gtk_curve_size_graph (GtkCurve *curve)
static void
gtk_curve_reset_vector (GtkCurve *curve)
{
if (curve->ctlpoint)
g_free (curve->ctlpoint);
g_free (curve->ctlpoint);
curve->num_ctlpoints = 2;
curve->ctlpoint = g_malloc (2 * sizeof (curve->ctlpoint[0]));
......@@ -1030,10 +1027,8 @@ gtk_curve_finalize (GObject *object)
curve = GTK_CURVE (object);
if (curve->pixmap)
g_object_unref (curve->pixmap);
if (curve->point)
g_free (curve->point);
if (curve->ctlpoint)
g_free (curve->ctlpoint);
g_free (curve->point);
g_free (curve->ctlpoint);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
......
......@@ -3402,8 +3402,7 @@ gtk_entry_create_layout (GtkEntry *entry,
pango_layout_set_attributes (layout, tmp_attrs);
if (preedit_string)
g_free (preedit_string);
g_free (preedit_string);
if (preedit_attrs)
pango_attr_list_unref (preedit_attrs);
......
......@@ -573,8 +573,7 @@ gtk_entry_completion_finalize (GObject *object)
if (priv->action_view)
g_object_unref (priv->action_view);
if (priv->case_normalized_key)
g_free (priv->case_normalized_key);
g_free (priv->case_normalized_key);
if (priv->popup_window)
gtk_widget_destroy (priv->popup_window);
......@@ -1095,8 +1094,7 @@ gtk_entry_completion_complete (GtkEntryCompletion *completion)
if (!completion->priv->filter_model)
return;
if (completion->priv->case_normalized_key)
g_free (completion->priv->case_normalized_key);
g_free (completion->priv->case_normalized_key);
tmp = g_utf8_normalize (gtk_entry_get_text (GTK_ENTRY (completion->priv->entry)),
-1, G_NORMALIZE_ALL);
......
......@@ -846,8 +846,7 @@ gtk_file_chooser_entry_changed (GtkEditable *editable)
file_part_pos = 0;
}
if (chooser_entry->file_part)
g_free (chooser_entry->file_part);
g_free (chooser_entry->file_part);
chooser_entry->file_part = file_part;
chooser_entry->file_part_pos = file_part_pos;
......
......@@ -130,8 +130,7 @@ gtk_file_filter_finalize (GObject *object)
g_slist_foreach (filter->rules, (GFunc)filter_rule_free, NULL);
g_slist_free (filter->rules);
if (filter->name)
g_free (filter->name);
g_free (filter->name);
G_OBJECT_CLASS (gtk_file_filter_parent_class)->finalize (object);
}
......@@ -179,8 +178,7 @@ gtk_file_filter_set_name (GtkFileFilter *filter,
{
g_return_if_fail (GTK_IS_FILE_FILTER (filter));
if (filter->name)
g_free (filter->name);
g_free (filter->name);
filter->name = g_strdup (name);
}
......
......@@ -2386,8 +2386,7 @@ gtk_file_selection_file_changed (GtkTreeSelection *selection,
if (index != -1)
{
if (fs->last_selected != NULL)
g_free (fs->last_selected);
g_free (fs->last_selected);
fs->last_selected = g_strdup (g_ptr_array_index (new_names, index));
filename = get_real_filename (fs->last_selected, FALSE);
......@@ -2701,14 +2700,10 @@ cmpl_free_state (CompletionState* cmpl_state)
cmpl_free_dir_list (cmpl_state->directory_storage);
cmpl_free_dir_sent_list (cmpl_state->directory_sent_storage);
if (cmpl_state->user_dir_name_buffer)
g_free (cmpl_state->user_dir_name_buffer);
if (cmpl_state->user_directories)
g_free (cmpl_state->user_directories);
if (cmpl_state->the_completion.text)
g_free (cmpl_state->the_completion.text);
if (cmpl_state->updated_text)
g_free (cmpl_state->updated_text);
g_free (cmpl_state->user_dir_name_buffer);
g_free (cmpl_state->user_directories);
g_free (cmpl_state->the_completion.text);
g_free (cmpl_state->updated_text);
g_free (cmpl_state);
}
......@@ -3948,10 +3943,8 @@ get_pwdb (CompletionState* cmpl_state)
error:
if (cmpl_state->user_dir_name_buffer)
g_free (cmpl_state->user_dir_name_buffer);
if (cmpl_state->user_directories)
g_free (cmpl_state->user_directories);
g_free (cmpl_state->user_dir_name_buffer);
g_free (cmpl_state->user_directories);
cmpl_state->user_dir_name_buffer = NULL;
cmpl_state->user_directories = NULL;
......
......@@ -103,14 +103,10 @@ gtk_file_info_free (GtkFileInfo *info)
{
g_return_if_fail (info != NULL);
if (info->display_name)
g_free (info->display_name);
if (info->mime_type)
g_free (info->mime_type);
if (info->display_key)
g_free (info->display_key);
if (info->icon_name)
g_free (info->icon_name);
g_free (info->display_name);
g_free (info->mime_type);
g_free (info->display_key);
g_free (info->icon_name);
g_free (info);
}
......@@ -158,8 +154,7 @@ gtk_file_info_set_display_name (GtkFileInfo *info,
if (display_name == info->display_name)
return;
if (info->display_name)
g_free (info->display_name);
g_free (info->display_name);
if (info->display_key)
{
g_free (info->display_key);
......@@ -217,8 +212,7 @@ gtk_file_info_set_mime_type (GtkFileInfo *info,
{
g_return_if_fail (info != NULL);
if (info->mime_type)
g_free (info->mime_type);
g_free (info->mime_type);
info->mime_type = g_strdup (mime_type);
}
......@@ -264,8 +258,7 @@ gtk_file_info_set_icon_name (GtkFileInfo *info,
{
g_return_if_fail (info != NULL);
if (info->icon_name)
g_free (info->icon_name);
g_free (info->icon_name);
info->icon_name = g_strdup (icon_name);
}
......
......@@ -999,10 +999,8 @@ insert_theme (GtkIconTheme *icon_theme, const char *theme_name)
static void
free_unthemed_icon (UnthemedIcon *unthemed_icon)
{
if (unthemed_icon->svg_filename)
g_free (unthemed_icon->svg_filename);
if (unthemed_icon->no_svg_filename)
g_free (unthemed_icon->no_svg_filename);
g_free (unthemed_icon->svg_filename);
g_free (unthemed_icon->no_svg_filename);
g_slice_free (UnthemedIcon, unthemed_icon);
}
......@@ -2434,11 +2432,9 @@ gtk_icon_info_free (GtkIconInfo *icon_info)
{
g_return_if_fail (icon_info != NULL);
if (icon_info->filename)
g_free (icon_info->filename);
g_free (icon_info->filename);
#ifdef G_OS_WIN32
if (icon_info->cp_filename)
g_free (icon_info->cp_filename);
g_free (icon_info->cp_filename);
#endif
if (icon_info->pixbuf)
g_object_unref (icon_info->pixbuf);
......@@ -2560,8 +2556,7 @@ load_svg_at_size (const gchar *filename,
bail:
if (loader)
g_object_unref (loader);
if (contents)
g_free (contents);
g_free (contents);
return pixbuf;
}
......
......@@ -7017,8 +7017,7 @@ gtk_icon_view_item_accessible_action_set_description (AtkAction *action,
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (action);
if (item->action_descriptions[i])
g_free (item->action_descriptions[i]);
g_free (item->action_descriptions[i]);
item->action_descriptions[i] = g_strdup (description);
......
......@@ -1894,8 +1894,7 @@ gtk_image_reset (GtkImage *image)
break;
case GTK_IMAGE_ICON_NAME:
if (image->data.name.icon_name)
g_free (image->data.name.icon_name);
g_free (image->data.name.icon_name);
image->data.name.icon_name = NULL;
if (image->data.name.pixbuf)
g_object_unref (image->data.name.pixbuf);
......
......@@ -1144,8 +1144,7 @@ button_data_free (ButtonData *button_data)
gtk_file_path_free (button_data->path);
button_data->path = NULL;
if (button_data->dir_name)
g_free (button_data->dir_name);
g_free (button_data->dir_name);
button_data->dir_name = NULL;
button_data->button = NULL;
......
......@@ -200,8 +200,7 @@ gtk_preview_size (GtkPreview *preview,
GTK_WIDGET (preview)->requisition.width = width;
GTK_WIDGET (preview)->requisition.height = height;
if (preview->buffer)
g_free (preview->buffer);
g_free (preview->buffer);
preview->buffer = NULL;
}
}
......@@ -416,8 +415,7 @@ gtk_preview_finalize (GObject *object)
g_return_if_fail (GTK_IS_PREVIEW (object));
preview = GTK_PREVIEW (object);
if (preview->buffer)
g_free (preview->buffer);
g_free (preview->buffer);
preview->type = (GtkPreviewType) -1;
G_OBJECT_CLASS (gtk_preview_parent_class)->finalize (object);
......@@ -549,8 +547,7 @@ gtk_preview_make_buffer (GtkPreview *preview)
(preview->buffer_width != width) ||
(preview->buffer_height != height))
{
if (preview->buffer)
g_free (preview->buffer);
g_free (preview->buffer);
preview->buffer_width = width;
preview->buffer_height = height;
......
......@@ -273,8 +273,7 @@ gtk_progress_finalize (GObject *object)