bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: localcharset.c


From: Bruno Haible
Subject: Re: localcharset.c
Date: Mon, 28 Feb 2011 23:43:02 +0100
User-agent: KMail/1.9.9

Simon Josefsson wrote:
> Make syntax-check complains about this in localcharset.c:
> 
>                           if (old_res_ptr != NULL)
>                             free (old_res_ptr);
> 
> maint.mk: found useless "if" before "free" above

I wouldn't use this rule in general, because whether the 'if' is appropriate
depends on the situation. But in this place the code is not speed critical
at all, so removing the 'if' is fine. I've done it:


2011-02-28  Bruno Haible  <address@hidden>

        localcharset: Assume ANSI C behaviour of free().
        * lib/localcharset.c (get_charset_aliases): Remove NULL test before
        calling free().
        Suggested by Simon Josefsson <address@hidden>.

--- lib/localcharset.c.orig     Mon Feb 28 23:37:47 2011
+++ lib/localcharset.c  Mon Feb 28 23:36:30 2011
@@ -228,8 +228,7 @@
                         {
                           /* Out of memory. */
                           res_size = 0;
-                          if (old_res_ptr != NULL)
-                            free (old_res_ptr);
+                          free (old_res_ptr);
                           break;
                         }
                       strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);

-- 
In memoriam Olof Palme <http://en.wikipedia.org/wiki/Olof_Palme>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]