# HG changeset patch
# User Anthony PERARD <anthony.perard@xxxxxxxxxx>
# Date 1317310102 -3600
# Node ID 952e0118a7c47c467c34f24f9c271902eed3bc99
# Parent f51dcd8acb7b950c870d23d250f56ad542997ae9
libxl: Introduce libxl__realloc.
Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
diff -r f51dcd8acb7b -r 952e0118a7c4 tools/libxl/libxl_internal.c
--- a/tools/libxl/libxl_internal.c Thu Sep 29 16:28:22 2011 +0100
+++ b/tools/libxl/libxl_internal.c Thu Sep 29 16:28:22 2011 +0100
@@ -102,6 +102,30 @@
return ptr;
}
+void *libxl__realloc(libxl__gc *gc, void *ptr, size_t new_size)
+{
+ void *new_ptr = realloc(ptr, new_size);
+ int i = 0;
+
+ if (new_ptr == NULL && new_size != 0) {
+ return NULL;
+ }
+
+ if (ptr == NULL) {
+ libxl__ptr_add(gc, new_ptr);
+ } else if (new_ptr != ptr) {
+ for (i = 0; i < gc->alloc_maxsize; i++) {
+ if (gc->alloc_ptrs[i] == ptr) {
+ gc->alloc_ptrs[i] = new_ptr;
+ break;
+ }
+ }
+ }
+
+
+ return new_ptr;
+}
+
char *libxl__sprintf(libxl__gc *gc, const char *fmt, ...)
{
char *s;
diff -r f51dcd8acb7b -r 952e0118a7c4 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h Thu Sep 29 16:28:22 2011 +0100
+++ b/tools/libxl/libxl_internal.h Thu Sep 29 16:28:22 2011 +0100
@@ -145,6 +145,7 @@
_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);
+_hidden void *libxl__realloc(libxl__gc *gc, void *ptr, size_t new_size);
_hidden char *libxl__sprintf(libxl__gc *gc, const char *fmt, ...)
PRINTF_ATTRIBUTE(2, 3);
_hidden char *libxl__strdup(libxl__gc *gc, const char *c);
_hidden char *libxl__dirname(libxl__gc *gc, const char *s);
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|