WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH 2 of 3] xenpaging: Fix-up xenpaging tool code

To: Patrick Colp <pjcolp@xxxxxxxxx>, Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 2 of 3] xenpaging: Fix-up xenpaging tool code
From: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Date: Wed, 28 Jul 2010 16:06:45 +0100
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Wed, 28 Jul 2010 08:07:30 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <AANLkTimhFnLgX4X8r3t7fdREZ6xvetPjhZCkWGv2O3d2@xxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcsuZVn1a2KAxJdZSE6vEh4r086oAgAASRNR
Thread-topic: [Xen-devel] [PATCH 2 of 3] xenpaging: Fix-up xenpaging tool code
User-agent: Microsoft-Entourage/12.24.0.100205
On 28/07/2010 15:57, "Patrick Colp" <pjcolp@xxxxxxxxx> wrote:

>>> ++        free(paging->bitmap);
>> 
>> since free(0) is legal and a no-op ?
> 
> 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



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel