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

Re: [Xen-devel] Re: [PATCH RESEND V8 4/7] libxl: Introduce libxl__reallo

To: Ian Campbell <Ian.Campbell@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] Re: [PATCH RESEND V8 4/7] libxl: Introduce libxl__realloc.
From: Christoph Egger <Christoph.Egger@xxxxxxx>
Date: Thu, 22 Sep 2011 10:17:17 +0200
Cc: Anthony Perard <anthony.perard@xxxxxxxxxx>, Xen Devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>
Delivery-date: Thu, 22 Sep 2011 01:19:29 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1316619995.3891.221.camel@xxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1316609997-26002-1-git-send-email-anthony.perard@xxxxxxxxxx> <1316609997-26002-5-git-send-email-anthony.perard@xxxxxxxxxx> <1316612077.3891.187.camel@xxxxxxxxxxxxxxxxxxxxxx> <4E79ED94.1000308@xxxxxxx> <1316619995.3891.221.camel@xxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; NetBSD amd64; en-US; rv:1.9.2.17) Gecko/20110523 Lightning/1.0b3pre Thunderbird/3.1.10
On 09/21/11 17:46, Ian Campbell wrote:
On Wed, 2011-09-21 at 14:58 +0100, Christoph Egger wrote:
On 09/21/11 15:34, Ian Campbell wrote:
On Wed, 2011-09-21 at 13:59 +0100, Anthony PERARD wrote:
Signed-off-by: Anthony PERARD<anthony.perard@xxxxxxxxxx>

Acked-by: Ian Campbell<ian.campbell@xxxxxxxxxx>

---
   tools/libxl/libxl_internal.c |   24 ++++++++++++++++++++++++
   tools/libxl/libxl_internal.h |    1 +
   2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
index e259278..c4d54f9 100644
--- a/tools/libxl/libxl_internal.c
+++ b/tools/libxl/libxl_internal.c
@@ -102,6 +102,30 @@ void *libxl__calloc(libxl__gc *gc, size_t nmemb, size_t 
size)
       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 --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 739e45e..5d270bb 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -145,6 +145,7 @@ _hidden int libxl__ptr_add(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);

What is the difference between libxl__zalloc and libxl__calloc?

The interface they provide? One of them is effectively a convenience
version of the other. Surely you can look in the code and see this as
easily as anyone else.

I prefer a documentation.



+_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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel








--
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632


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

<Prev in Thread] Current Thread [Next in Thread>