debuggers.hg
changeset 22043:def814437d42
tools/libxl: remove libxl_free() since there are no more callers
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>
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>
author | Gianni Tedesco <gianni.tedesco@citrix.com> |
---|---|
date | Mon Aug 16 13:39:19 2010 +0100 (2010-08-16) |
parents | 1382296539fc |
children | 2f1f35359317 |
files | tools/libxl/libxl.h tools/libxl/libxl_internal.c tools/libxl/libxl_internal.h |
line diff
1.1 --- a/tools/libxl/libxl.h Mon Aug 16 13:37:58 2010 +0100 1.2 +++ b/tools/libxl/libxl.h Mon Aug 16 13:39:19 2010 +0100 1.3 @@ -117,10 +117,9 @@ 1.4 * and an internal wrapper adds the relevant pointers to the gc. 1.5 * The latter method is preferred for obvious performance reasons. 1.6 * 1.7 - * No temporary objects allocated from the pool should be explicitly freed. 1.8 - * Calling libxl_free_all() before returning from a public functions will do 1.9 - * this. The upshot of this is that almost all calls to libxl_free() are 1.10 - * erroneous. 1.11 + * No temporary objects allocated from the pool may be explicitly freed. 1.12 + * Therefore public functions which initialize a libxl_gc MUST call 1.13 + * libxl_free_all() before returning. 1.14 */ 1.15 #ifndef LIBXL_H 1.16 #define LIBXL_H
2.1 --- a/tools/libxl/libxl_internal.c Mon Aug 16 13:37:58 2010 +0100 2.2 +++ b/tools/libxl/libxl_internal.c Mon Aug 16 13:39:19 2010 +0100 2.3 @@ -59,25 +59,6 @@ int libxl_ptr_add(libxl_gc *gc, void *pt 2.4 return 0; 2.5 } 2.6 2.7 -void libxl_free(libxl_gc *gc, void *ptr) 2.8 -{ 2.9 - int i; 2.10 - 2.11 - if (!ptr) 2.12 - return; 2.13 - 2.14 - /* remove the pointer from the tracked ptrs */ 2.15 - for (i = 0; i < gc->alloc_maxsize; i++) { 2.16 - if (gc->alloc_ptrs[i] == ptr) { 2.17 - gc->alloc_ptrs[i] = NULL; 2.18 - free(ptr); 2.19 - return; 2.20 - } 2.21 - } 2.22 - /* haven't find the pointer, really bad */ 2.23 - abort(); 2.24 -} 2.25 - 2.26 void libxl_free_all(libxl_gc *gc) 2.27 { 2.28 void *ptr;
3.1 --- a/tools/libxl/libxl_internal.h Mon Aug 16 13:37:58 2010 +0100 3.2 +++ b/tools/libxl/libxl_internal.h Mon Aug 16 13:39:19 2010 +0100 3.3 @@ -129,7 +129,6 @@ static inline libxl_ctx *libxl_gc_owner( 3.4 3.5 /* memory allocation tracking/helpers */ 3.6 _hidden int libxl_ptr_add(libxl_gc *gc, void *ptr); 3.7 -_hidden void libxl_free(libxl_gc *gc, void *ptr); 3.8 _hidden void libxl_free_all(libxl_gc *gc); 3.9 _hidden void *libxl_zalloc(libxl_gc *gc, int bytes); 3.10 _hidden void *libxl_calloc(libxl_gc *gc, size_t nmemb, size_t size);