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-changelog

[Xen-changelog] [xen-unstable] xl: Return void from libxl_free() and lib

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xl: Return void from libxl_free() and libxl_free_all()
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 13 Aug 2010 02:15:30 -0700
Delivery-date: Fri, 13 Aug 2010 02:19:37 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User "Gianni Tedesco (3P)" <gianni.tedesco@xxxxxxxxxx>
# Date 1281528107 -3600
# Node ID 9d1bbf6959e46937e1ecab1f15b829c8ab55419b
# Parent  cb71d0d30f0ce90193b8bff641127a02d44182ac
xl: Return void from libxl_free() and libxl_free_all()
Also abort() if a pointer passed in to libxl_free() cannot be found in the
mini-gc structures. This exposes several real bugs (ie. not just the
libxl_free() something that was allocated via malloc variety).

Signed-off-by: Gianni Tedesco <gianni.tedesco@xxxxxxxxxx>
Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
---
 tools/libxl/libxl_internal.c |   15 +++++++--------
 tools/libxl/libxl_internal.h |    4 ++--
 2 files changed, 9 insertions(+), 10 deletions(-)

diff -r cb71d0d30f0c -r 9d1bbf6959e4 tools/libxl/libxl_internal.c
--- a/tools/libxl/libxl_internal.c      Tue Aug 10 15:35:13 2010 +0100
+++ b/tools/libxl/libxl_internal.c      Wed Aug 11 13:01:47 2010 +0100
@@ -59,26 +59,26 @@ int libxl_ptr_add(libxl_ctx *ctx, void *
     return 0;
 }
 
-int libxl_free(libxl_ctx *ctx, void *ptr)
+void libxl_free(libxl_ctx *ctx, void *ptr)
 {
     int i;
 
     if (!ptr)
-        return 0;
+        return;
 
     /* remove the pointer from the tracked ptrs */
     for (i = 0; i < ctx->alloc_maxsize; i++) {
         if (ctx->alloc_ptrs[i] == ptr) {
             ctx->alloc_ptrs[i] = NULL;
             free(ptr);
-            return 0;
+            return;
         }
     }
     /* haven't find the pointer, really bad */
-    return -1;
-}
-
-int libxl_free_all(libxl_ctx *ctx)
+    abort();
+}
+
+void libxl_free_all(libxl_ctx *ctx)
 {
     void *ptr;
     int i;
@@ -88,7 +88,6 @@ int libxl_free_all(libxl_ctx *ctx)
         ctx->alloc_ptrs[i] = NULL;
         free(ptr);
     }
-    return 0;
 }
 
 void *libxl_zalloc(libxl_ctx *ctx, int bytes)
diff -r cb71d0d30f0c -r 9d1bbf6959e4 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Tue Aug 10 15:35:13 2010 +0100
+++ b/tools/libxl/libxl_internal.h      Wed Aug 11 13:01:47 2010 +0100
@@ -108,8 +108,8 @@ int xs_writev(struct xs_handle *xsh, xs_
 
 /* memory allocation tracking/helpers */
 int libxl_ptr_add(libxl_ctx *ctx, void *ptr);
-int libxl_free(libxl_ctx *ctx, void *ptr);
-int libxl_free_all(libxl_ctx *ctx);
+void libxl_free(libxl_ctx *ctx, void *ptr);
+void libxl_free_all(libxl_ctx *ctx);
 void *libxl_zalloc(libxl_ctx *ctx, int bytes);
 void *libxl_calloc(libxl_ctx *ctx, size_t nmemb, size_t size);
 char *libxl_sprintf(libxl_ctx *ctx, const char *fmt, ...) PRINTF_ATTRIBUTE(2, 
3);

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xl: Return void from libxl_free() and libxl_free_all(), Xen patchbot-unstable <=