From mboxrd@z Thu Jan 1 00:00:00 1970 From: Keir Fraser Subject: Re: [PATCH 2 of 3] xenpaging: Fix-up xenpaging tool code Date: Wed, 28 Jul 2010 16:06:45 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Patrick Colp , Ian Jackson Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org On 28/07/2010 15:57, "Patrick Colp" wrote: >>> ++ =A0 =A0 =A0 =A0free(paging->bitmap); >>=20 >> since free(0) is legal and a no-op ? >=20 > Could do, but free(0) isn't exactly a no-op. free() does a check to > see if the pointer passed was 0. So it doesn't really make much > difference if I do the check or let it do the check. I can easily > change the code to just do free(paging->bitmap) though, if that's the > preferred way to do it. Actually, I would argue my way is better since > in the case of a NULL pointer, the free function isn't called at all, > which saves a bunch of cycles. Avoiding the if is better. Everyone knows free(0) is legal, so it's idiomatic to unconditionally call free(). -- Keir