tools/libxl: remove libxl_free() since there are no more callers
authorGianni Tedesco <gianni.tedesco@citrix.com>
Mon, 16 Aug 2010 12:39:19 +0000 (13:39 +0100)
committerGianni Tedesco <gianni.tedesco@citrix.com>
Mon, 16 Aug 2010 12:39:19 +0000 (13:39 +0100)
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.

Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxl.h
tools/libxl/libxl_internal.c
tools/libxl/libxl_internal.h

index 2d289735d816359c7739ef01d83988a96c3177ba..fe117377c500be6332e041eb59d789d43ba14bf2 100644 (file)
  *     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
index 2d5ad9a0332896e404ce2d5fc06206770cc85e1b..5eb27a6f4d790a6cb6644f3d328b1e219739ab9e 100644 (file)
@@ -59,25 +59,6 @@ int libxl_ptr_add(libxl_gc *gc, void *ptr)
     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;
index fecb009e7c19ce3fd5a651e8dd51102c353fece5..dc6e1c8e8fcbda248dfec7c77539be3c88eb78e5 100644 (file)
@@ -129,7 +129,6 @@ static inline libxl_ctx *libxl_gc_owner(libxl_gc *gc)
 
 /* 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);