diff options
author | "Gianni Tedesco (3P)" <gianni.tedesco@citrix.com> | 2010-08-11 13:01:47 +0100 |
---|---|---|
committer | "Gianni Tedesco (3P)" <gianni.tedesco@citrix.com> | 2010-08-11 13:01:47 +0100 |
commit | f94a432a98d3748edf17bb4a6e1b35a29eefb9d5 (patch) | |
tree | d0523607e82f4078a8141dbd088d2c6f2534823d /tools/libxl/libxl_internal.c | |
parent | d5caa669daa5b803e3e8dcf9cdebd1b0f7e42a57 (diff) | |
download | xen-f94a432a98d3748edf17bb4a6e1b35a29eefb9d5.tar.gz xen-f94a432a98d3748edf17bb4a6e1b35a29eefb9d5.tar.bz2 xen-f94a432a98d3748edf17bb4a6e1b35a29eefb9d5.zip |
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@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Diffstat (limited to 'tools/libxl/libxl_internal.c')
-rw-r--r-- | tools/libxl/libxl_internal.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c index a0179b4e46..22595f1578 100644 --- a/tools/libxl/libxl_internal.c +++ b/tools/libxl/libxl_internal.c @@ -59,26 +59,26 @@ int libxl_ptr_add(libxl_ctx *ctx, void *ptr) 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; + abort(); } -int libxl_free_all(libxl_ctx *ctx) +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) |