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

[Xen-devel] [PATCH]: zap libxl_free() since there are no more callers

To: Xen Devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH]: zap libxl_free() since there are no more callers
From: Gianni Tedesco <gianni.tedesco@xxxxxxxxxx>
Date: Fri, 13 Aug 2010 17:25:41 +0100
Cc: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Delivery-date: Fri, 13 Aug 2010 09:30:56 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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
libxl_free() allows allocated memory to be explicitly free'd from a
libxl_gc. Every previous use of this function has now been made
redundant and therefore has been removed. We can safely kill it and
amend the policy accordingly.

diff -r 8d0ebf3993aa tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Fri Aug 13 17:25:23 2010 +0100
+++ b/tools/libxl/libxl.h       Fri Aug 13 17:27:47 2010 +0100
@@ -117,10 +117,9 @@
  *     and an internal wrapper adds the relevant pointers to the gc.
  *     The latter method is preferred for obvious performance reasons.
  *
- * No temporary objects allocated from the pool should be explicitly freed.
- * Calling libxl_free_all() before returning from a public functions will do
- * this. The upshot of this is that almost all calls to libxl_free() are
- * erroneous.
+ * No temporary objects allocated from the pool may be explicitly freed.
+ * Therefore public functions which initialize a libxl_gc MUST call
+ * libxl_free_all() before returning.
  */
 #ifndef LIBXL_H
 #define LIBXL_H
diff -r 8d0ebf3993aa tools/libxl/libxl_internal.c
--- a/tools/libxl/libxl_internal.c      Fri Aug 13 17:25:23 2010 +0100
+++ b/tools/libxl/libxl_internal.c      Fri Aug 13 17:27:47 2010 +0100
@@ -59,25 +59,6 @@ int libxl_ptr_add(libxl_gc *gc, void *pt
     return 0;
 }
 
-void libxl_free(libxl_gc *gc, void *ptr)
-{
-    int i;
-
-    if (!ptr)
-        return;
-
-    /* remove the pointer from the tracked ptrs */
-    for (i = 0; i < gc->alloc_maxsize; i++) {
-        if (gc->alloc_ptrs[i] == ptr) {
-            gc->alloc_ptrs[i] = NULL;
-            free(ptr);
-            return;
-        }
-    }
-    /* haven't find the pointer, really bad */
-    abort();
-}
-
 void libxl_free_all(libxl_gc *gc)
 {
     void *ptr;
diff -r 8d0ebf3993aa tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Fri Aug 13 17:25:23 2010 +0100
+++ b/tools/libxl/libxl_internal.h      Fri Aug 13 17:27:47 2010 +0100
@@ -129,7 +129,6 @@ static inline libxl_ctx *libxl_gc_owner(
 
 /* memory allocation tracking/helpers */
 _hidden int libxl_ptr_add(libxl_gc *gc, void *ptr);
-_hidden void libxl_free(libxl_gc *gc, void *ptr);
 _hidden void libxl_free_all(libxl_gc *gc);
 _hidden void *libxl_zalloc(libxl_gc *gc, int bytes);
 _hidden void *libxl_calloc(libxl_gc *gc, size_t nmemb, size_t size);



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

<Prev in Thread] Current Thread [Next in Thread>