summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2008-06-02 06:09:17 +0000
committerJim Meyering <jim@meyering.net>2008-06-02 06:09:17 +0000
commit70fdbb46cd40f9376333e10c9284873d3a3a787f (patch)
treed087a93bc6d9be911fce5e28e1112f6c5dfddb09
parent5c19cd0bbb8f3b8142c0b8f90eebdd84b7a3eb29 (diff)
downloademacs-70fdbb46cd40f9376333e10c9284873d3a3a787f.tar.gz
Make "xfree (NULL)" a no-op; remove useless if-before-xfree.
* src/alloc.c (xfree): Return right away for a NULL arg. * src/lread.c (nosuffix): Remove now-useless if-before-xfree tests. * src/gtkutil.c (xg_gtk_scroll_destroy): Likewise. * src/mac.c (create_apple_event_from_event_ref): Likewise. (create_apple_event_from_drag_ref, cfstring_create_normalized): Likewise. * src/doprnt.c (doprnt1): Likewise. * src/frame.c (frame): Likewise. * src/keyboard.c (wipe_kboard): Likewise. * src/macterm.c (x_free_frame_resources, xlfdpat_destroy, XFreePixmap): (init_font_name_table, mac_unload_font, x_delete_display): Likewise. * src/term.c (tty_default_color_capabilities, maybe_fatal) (delete_tty): Likewise. * src/w16select.c (string): Likewise. * src/w32.c (w32_get_resource, SET_ENV_BUF_SIZE): Likewise. * src/w32bdf.c (w32_free_bdf_font): Likewise. * src/w32fns.c (w32_unload_font): Likewise. * src/w32font.c (w32font_close): Likewise. * src/window.c (size_window): Likewise. * src/xselect.c (receive_incremental_selection): Likewise. * src/xterm.c (x_free_frame_resources, x_delete_display): Likewise. * src/mactoolbox.c (create_apple_event_from_drag_ref): Likewise. * src/w32.c (stat): Likewise.
-rw-r--r--lib-src/ChangeLog8
-rw-r--r--lwlib/ChangeLog4
-rw-r--r--src/ChangeLog38
-rw-r--r--src/alloc.c2
-rw-r--r--src/doprnt.c3
-rw-r--r--src/frame.c21
-rw-r--r--src/gtkutil.c2
-rw-r--r--src/keyboard.c3
-rw-r--r--src/lread.c3
-rw-r--r--src/mac.c9
-rw-r--r--src/macterm.c27
-rw-r--r--src/mactoolbox.c3
-rw-r--r--src/term.c26
-rw-r--r--src/w16select.c3
-rw-r--r--src/w32.c9
-rw-r--r--src/w32bdf.c8
-rw-r--r--src/w32fns.c2
-rw-r--r--src/window.c2
-rw-r--r--src/xselect.c2
-rw-r--r--src/xterm.c10
20 files changed, 86 insertions, 99 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index 95d06f5dfc1..b2edff07814 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,12 +1,12 @@
2008-06-02 Jim Meyering <meyering@redhat.com>
- * lib-src/ebrowse.c (xfree): Remove definition; s/xfree/free/
+ * ebrowse.c (xfree): Remove definition; s/xfree/free/
remove useless if-before-free tests
- * lib-src/ebrowse.c (xfree): Likewise.
- * lib-src/etags.c (process_file_name, free_tree, free_fdesc): Likewise.
+ * ebrowse.c (xfree): Likewise.
+ * etags.c (process_file_name, free_tree, free_fdesc): Likewise.
(popclass_above, Prolog_functions, Erlang_functions): Likewise.
- * lib-src/pop.c (pop_quit): Likewise.
+ * pop.c (pop_quit): Likewise.
2008-05-30 Juanma Barranquero <lekktu@gmail.com>
diff --git a/lwlib/ChangeLog b/lwlib/ChangeLog
index 17147cf1d92..4fd03926ce3 100644
--- a/lwlib/ChangeLog
+++ b/lwlib/ChangeLog
@@ -1,8 +1,8 @@
2008-06-02 Jim Meyering <meyering@redhat.com>
remove useless if-before-free tests
- * lwlib/lwlib-Xm.c (xm_update_one_value): Likewise.
- * lwlib/lwlib.c (safe_free_str, free_widget_value_tree): Likewise.
+ * lwlib-Xm.c (xm_update_one_value): Likewise.
+ * lwlib.c (safe_free_str, free_widget_value_tree): Likewise.
2008-04-18 Stefan Monnier <monnier@iro.umontreal.ca>
diff --git a/src/ChangeLog b/src/ChangeLog
index 5d071f0c764..d7db9c29588 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,13 +1,37 @@
2008-06-02 Jim Meyering <meyering@redhat.com>
+ Make "xfree (NULL)" a no-op; remove useless if-before-xfree.
+ * alloc.c (xfree): Return right away for a NULL arg.
+ * lread.c (nosuffix): Remove now-useless if-before-xfree tests.
+ * gtkutil.c (xg_gtk_scroll_destroy): Likewise.
+ * mac.c (create_apple_event_from_event_ref): Likewise.
+ (create_apple_event_from_drag_ref, cfstring_create_normalized): Likewise.
+ * doprnt.c (doprnt1): Likewise.
+ * frame.c (frame): Likewise.
+ * keyboard.c (wipe_kboard): Likewise.
+ * macterm.c (x_free_frame_resources, xlfdpat_destroy, XFreePixmap):
+ (init_font_name_table, mac_unload_font, x_delete_display): Likewise.
+ * term.c (tty_default_color_capabilities, maybe_fatal)
+ (delete_tty): Likewise.
+ * w16select.c (string): Likewise.
+ * w32.c (w32_get_resource, SET_ENV_BUF_SIZE): Likewise.
+ * w32bdf.c (w32_free_bdf_font): Likewise.
+ * w32fns.c (w32_unload_font): Likewise.
+ * w32font.c (w32font_close): Likewise.
+ * window.c (size_window): Likewise.
+ * xselect.c (receive_incremental_selection): Likewise.
+ * xterm.c (x_free_frame_resources, x_delete_display): Likewise.
+ * mactoolbox.c (create_apple_event_from_drag_ref): Likewise.
+ * w32.c (stat): Likewise.
+
remove useless if-before-free tests
- * src/editfns.c (Fset_time_zone_rule): Likewise.
- * src/lread.c (nosuffix): Likewise.
- * src/ralloc.c (get_bloc): Likewise.
- * src/regex.c (reg_free): Likewise.
- * src/xftfont.c (xftfont_open, xftfont_close): Likewise.
- * src/xrdb.c (get_user_app, get_environ_db, x_load_resources): Likewise.
- * src/xsmfns.c (smc_save_yourself_CB): Likewise.
+ * editfns.c (Fset_time_zone_rule): Likewise.
+ * lread.c (nosuffix): Likewise.
+ * ralloc.c (get_bloc): Likewise.
+ * regex.c (reg_free): Likewise.
+ * xftfont.c (xftfont_open, xftfont_close): Likewise.
+ * xrdb.c (get_user_app, get_environ_db, x_load_resources): Likewise.
+ * xsmfns.c (smc_save_yourself_CB): Likewise.
2008-06-02 Kenichi Handa <handa@m17n.org>
diff --git a/src/alloc.c b/src/alloc.c
index 031cb99b674..797b385fbd2 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -797,6 +797,8 @@ void
xfree (block)
POINTER_TYPE *block;
{
+ if (!block)
+ return;
MALLOC_BLOCK_INPUT;
free (block);
MALLOC_UNBLOCK_INPUT;
diff --git a/src/doprnt.c b/src/doprnt.c
index 05b194c9dbb..c7c27bac4c3 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -326,8 +326,7 @@ doprnt1 (lispstrings, buffer, bufsize, format, format_end, nargs, args)
};
/* If we had to malloc something, free it. */
- if (big_buffer)
- xfree (big_buffer);
+ xfree (big_buffer);
*bufptr = 0; /* Make sure our string end with a '\0' */
return bufptr - buffer;
diff --git a/src/frame.c b/src/frame.c
index 20812878c10..84a4e54d314 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -1477,20 +1477,13 @@ But FORCE inhibits this too. */)
Vframe_list = Fdelq (frame, Vframe_list);
FRAME_SET_VISIBLE (f, 0);
- if (f->namebuf)
- xfree (f->namebuf);
- if (f->decode_mode_spec_buffer)
- xfree (f->decode_mode_spec_buffer);
- if (FRAME_INSERT_COST (f))
- xfree (FRAME_INSERT_COST (f));
- if (FRAME_DELETEN_COST (f))
- xfree (FRAME_DELETEN_COST (f));
- if (FRAME_INSERTN_COST (f))
- xfree (FRAME_INSERTN_COST (f));
- if (FRAME_DELETE_COST (f))
- xfree (FRAME_DELETE_COST (f));
- if (FRAME_MESSAGE_BUF (f))
- xfree (FRAME_MESSAGE_BUF (f));
+ xfree (f->namebuf);
+ xfree (f->decode_mode_spec_buffer);
+ xfree (FRAME_INSERT_COST (f));
+ xfree (FRAME_DELETEN_COST (f));
+ xfree (FRAME_INSERTN_COST (f));
+ xfree (FRAME_DELETE_COST (f));
+ xfree (FRAME_MESSAGE_BUF (f));
/* Since some events are handled at the interrupt level, we may get
an event for f at any time; if we zero out the frame's terminal
diff --git a/src/gtkutil.c b/src/gtkutil.c
index fd0fbf778b2..afafee11916 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -3106,7 +3106,7 @@ xg_gtk_scroll_destroy (widget, data)
int id = (int) (EMACS_INT) data; /* The EMACS_INT cast avoids a warning. */
p = g_object_get_data (G_OBJECT (widget), XG_LAST_SB_DATA);
- if (p) xfree (p);
+ xfree (p);
xg_remove_widget_from_map (id);
}
diff --git a/src/keyboard.c b/src/keyboard.c
index 45f3d2f6194..5ac28a55247 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -11575,8 +11575,7 @@ static void
wipe_kboard (kb)
KBOARD *kb;
{
- if (kb->kbd_macro_buffer)
- xfree (kb->kbd_macro_buffer);
+ xfree (kb->kbd_macro_buffer);
}
#ifdef MULTI_KBOARD
diff --git a/src/lread.c b/src/lread.c
index 578addf1329..e5e77bc3477 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1273,8 +1273,7 @@ Return t if the file exists and loads successfully. */)
saved_doc_string = 0;
saved_doc_string_size = 0;
- if (prev_saved_doc_string)
- xfree (prev_saved_doc_string);
+ xfree (prev_saved_doc_string);
prev_saved_doc_string = 0;
prev_saved_doc_string_size = 0;
diff --git a/src/mac.c b/src/mac.c
index e549524bc1f..20872b2bdc9 100644
--- a/src/mac.c
+++ b/src/mac.c
@@ -906,8 +906,7 @@ mac_event_parameters_to_lisp (event, num_params, names, types)
break;
}
}
- if (buf)
- xfree (buf);
+ xfree (buf);
return result;
}
@@ -4778,10 +4777,8 @@ cfstring_create_normalized (str, symbol)
out_len / sizeof (UniChar));
if (uni)
DisposeUnicodeToTextInfo (&uni);
- if (out_buf)
- xfree (out_buf);
- if (buffer)
- xfree (buffer);
+ xfree (out_buf);
+ xfree (buffer);
}
else
{
diff --git a/src/macterm.c b/src/macterm.c
index ae9aa1108d2..2871bfa1179 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -910,8 +910,7 @@ XFreePixmap (display, pixmap)
#if USE_MAC_IMAGE_IO
if (pixmap)
{
- if (pixmap->data)
- xfree (pixmap->data);
+ xfree (pixmap->data);
xfree (pixmap);
}
#else
@@ -7390,8 +7389,7 @@ x_free_frame_resources (f)
x_free_gcs (f);
- if (FRAME_SIZE_HINTS (f))
- xfree (FRAME_SIZE_HINTS (f));
+ xfree (FRAME_SIZE_HINTS (f));
xfree (f->output_data.mac);
f->output_data.mac = NULL;
@@ -7640,8 +7638,7 @@ xlfdpat_destroy (pat)
{
if (pat->buf)
{
- if (pat->blocks)
- xfree (pat->blocks);
+ xfree (pat->blocks);
xfree (pat->buf);
}
xfree (pat);
@@ -8364,8 +8361,7 @@ init_font_name_table ()
HASH_VALUE (h, j));
prev_family = family;
}
- if (font_ids)
- xfree (font_ids);
+ xfree (font_ids);
}
#endif
@@ -9242,20 +9238,17 @@ mac_unload_font (dpyinfo, font)
int i;
for (i = font->min_byte1; i <= font->max_byte1; i++)
- if (font->bounds.rows[i])
- xfree (font->bounds.rows[i]);
+ xfree (font->bounds.rows[i]);
xfree (font->bounds.rows);
ATSUDisposeStyle (font->mac_style);
}
else
#endif
- if (font->bounds.per_char)
- xfree (font->bounds.per_char);
+ xfree (font->bounds.per_char);
#if USE_CG_TEXT_DRAWING
if (font->cg_font)
CGFontRelease (font->cg_font);
- if (font->cg_glyphs)
- xfree (font->cg_glyphs);
+ xfree (font->cg_glyphs);
#endif
xfree (font);
}
@@ -13026,12 +13019,10 @@ x_delete_display (dpyinfo)
if (dpyinfo->font_table)
{
- if (dpyinfo->font_table->font_encoder)
- xfree (dpyinfo->font_table->font_encoder);
+ xfree (dpyinfo->font_table->font_encoder);
xfree (dpyinfo->font_table);
}
- if (dpyinfo->mac_id_name)
- xfree (dpyinfo->mac_id_name);
+ xfree (dpyinfo->mac_id_name);
if (x_display_list == 0)
{
diff --git a/src/mactoolbox.c b/src/mactoolbox.c
index b5e87a3c672..a73578d5205 100644
--- a/src/mactoolbox.c
+++ b/src/mactoolbox.c
@@ -6091,8 +6091,7 @@ create_apple_event_from_drag_ref (drag, num_types, types, result)
if (err != noErr)
break;
}
- if (buf)
- xfree (buf);
+ xfree (buf);
if (err == noErr)
{
diff --git a/src/term.c b/src/term.c
index 7636f22db75..533104dc040 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2090,17 +2090,14 @@ tty_default_color_capabilities (struct tty_display_info *tty, int save)
if (save)
{
- if (default_orig_pair)
- xfree (default_orig_pair);
+ xfree (default_orig_pair);
default_orig_pair = tty->TS_orig_pair ? xstrdup (tty->TS_orig_pair) : NULL;
- if (default_set_foreground)
- xfree (default_set_foreground);
+ xfree (default_set_foreground);
default_set_foreground = tty->TS_set_foreground ? xstrdup (tty->TS_set_foreground)
: NULL;
- if (default_set_background)
- xfree (default_set_background);
+ xfree (default_set_background);
default_set_background = tty->TS_set_background ? xstrdup (tty->TS_set_background)
: NULL;
@@ -3833,8 +3830,7 @@ maybe_fatal (must_succeed, buffer, terminal, str1, str2, arg1, arg2)
struct terminal *terminal;
char *str1, *str2, *arg1, *arg2;
{
- if (buffer)
- xfree (buffer);
+ xfree (buffer);
if (terminal)
delete_tty (terminal);
@@ -3915,11 +3911,8 @@ delete_tty (struct terminal *terminal)
delete_terminal (terminal);
- if (tty->name)
- xfree (tty->name);
-
- if (tty->type)
- xfree (tty->type);
+ xfree (tty->name);
+ xfree (tty->type);
if (tty->input)
{
@@ -3932,11 +3925,8 @@ delete_tty (struct terminal *terminal)
if (tty->termscript)
fclose (tty->termscript);
- if (tty->old_tty)
- xfree (tty->old_tty);
-
- if (tty->Wcm)
- xfree (tty->Wcm);
+ xfree (tty->old_tty);
+ xfree (tty->Wcm);
bzero (tty, sizeof (struct tty_display_info));
xfree (tty);
diff --git a/src/w16select.c b/src/w16select.c
index 24e92b24dfb..177a84f5e3b 100644
--- a/src/w16select.c
+++ b/src/w16select.c
@@ -565,8 +565,7 @@ DEFUN ("w16-set-clipboard-data", Fw16_set_clipboard_data, Sw16_set_clipboard_dat
ok = 0;
unblock:
- if (dst)
- xfree (dst);
+ xfree (dst);
UNBLOCK_INPUT;
/* Notify user if the text is too large to fit into DOS memory.
diff --git a/src/w32.c b/src/w32.c
index 36635a433f5..81accb6b610 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -1128,7 +1128,7 @@ w32_get_resource (key, lpdwtype)
return (lpvalue);
}
- if (lpvalue) xfree (lpvalue);
+ xfree (lpvalue);
RegCloseKey (hrootkey);
}
@@ -1145,7 +1145,7 @@ w32_get_resource (key, lpdwtype)
return (lpvalue);
}
- if (lpvalue) xfree (lpvalue);
+ xfree (lpvalue);
RegCloseKey (hrootkey);
}
@@ -1346,7 +1346,7 @@ init_environment (char ** argv)
/* Also ignore empty environment variables. */
|| *lpval == 0)
{
- if (lpval) xfree (lpval);
+ xfree (lpval);
lpval = env_vars[i].def_value;
dwType = REG_EXPAND_SZ;
dont_free = 1;
@@ -2962,8 +2962,7 @@ stat (const char * path, struct stat * buf)
get_file_owner_and_group (NULL, name, buf);
}
- if (psd)
- xfree (psd);
+ xfree (psd);
#if 0
/* Not sure if there is any point in this. */
diff --git a/src/w32bdf.c b/src/w32bdf.c
index e7fbe51b146..e9a1e63569e 100644
--- a/src/w32bdf.c
+++ b/src/w32bdf.c
@@ -304,10 +304,10 @@ w32_free_bdf_font(bdffont *fontp)
CloseHandle(fontp->hfilemap);
CloseHandle(fontp->hfile);
- if (fontp->registry) xfree(fontp->registry);
- if (fontp->encoding) xfree(fontp->encoding);
- if (fontp->slant) xfree(fontp->slant);
-/* if (fontp->width) xfree(fontp->width); */
+ xfree(fontp->registry);
+ xfree(fontp->encoding);
+ xfree(fontp->slant);
+/* xfree(fontp->width); */
xfree(fontp->filename);
for(i = 0;i < BDF_FIRST_OFFSET_TABLE;i++)
diff --git a/src/w32fns.c b/src/w32fns.c
index b18a1233b8a..e83acf0711d 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -4955,7 +4955,7 @@ w32_unload_font (dpyinfo, font)
{
if (font)
{
- if (font->per_char) xfree (font->per_char);
+ xfree (font->per_char);
if (font->bdf) w32_free_bdf_font (font->bdf);
if (font->hfont) DeleteObject (font->hfont);
diff --git a/src/window.c b/src/window.c
index c5e8b56084b..295e45b25a8 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3195,7 +3195,7 @@ size_window (window, size, width_p, nodelete_p, first_only, last_only)
last_pos += new_size;
}
- if (new_sizes) xfree (new_sizes);
+ xfree (new_sizes);
/* We should have covered the parent exactly with child windows. */
xassert (size == last_pos - first_pos);
diff --git a/src/xselect.c b/src/xselect.c
index dd5c1dcc6ba..11ee5945a79 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -1673,7 +1673,7 @@ receive_incremental_selection (display, window, property, target_type,
XSelectInput (display, window, STANDARD_EVENT_SET);
/* Use xfree, not XFree, because x_get_window_property
calls xmalloc itself. */
- if (tmp_data) xfree (tmp_data);
+ xfree (tmp_data);
break;
}
diff --git a/src/xterm.c b/src/xterm.c
index a14a8ed20eb..fa7ffe5139e 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -9513,9 +9513,7 @@ x_free_frame_resources (f)
XFlush (FRAME_X_DISPLAY (f));
}
- if (f->output_data.x->saved_menu_event)
- xfree (f->output_data.x->saved_menu_event);
-
+ xfree (f->output_data.x->saved_menu_event);
xfree (f->output_data.x);
f->output_data.x = NULL;
@@ -10522,10 +10520,8 @@ x_delete_display (dpyinfo)
xim_close_dpy (dpyinfo);
#endif
- if (dpyinfo->x_id_name)
- xfree (dpyinfo->x_id_name);
- if (dpyinfo->color_cells)
- xfree (dpyinfo->color_cells);
+ xfree (dpyinfo->x_id_name);
+ xfree (dpyinfo->color_cells);
xfree (dpyinfo);
}