]> xenbits.xensource.com Git - people/vhanquez/xen-unstable.git/commitdiff
libxl: convert malloc() to libxl__zalloc(NULL, ...)
authorDario Faggioli <raistlin@linux.it>
Wed, 6 Jun 2012 11:46:17 +0000 (12:46 +0100)
committerDario Faggioli <raistlin@linux.it>
Wed, 6 Jun 2012 11:46:17 +0000 (12:46 +0100)
And ditch the error handling in libxl_get_cpu_topology()

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- define and use NOGC instead of NULL to allow improvements to this
          infrastructure in the future ]
Committed-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/libxl.c
tools/libxl/libxl_internal.h

index 58387ed0122f4f385fe2935faae1acd9ed3f4c0a..1f7ccc4aea66bf313d6ccc88e1d0bf399df600d2 100644 (file)
@@ -3116,12 +3116,7 @@ libxl_cputopology *libxl_get_cpu_topology(libxl_ctx *ctx, int *nr)
     if (tinfo.max_cpu_index < max_cpus - 1)
         max_cpus = tinfo.max_cpu_index + 1;
 
-    ret = malloc(sizeof(libxl_cputopology) * max_cpus);
-    if (ret == NULL) {
-        LIBXL__LOG_ERRNOVAL(ctx, XTL_ERROR, ENOMEM,
-                            "Unable to allocate return value");
-        goto fail;
-    }
+    ret = libxl__zalloc(NOGC, sizeof(libxl_cputopology) * max_cpus);
 
     for (i = 0; i < max_cpus; i++) {
 #define V(map, i) (map[i] == INVALID_TOPOLOGY_ID) ? \
index f647e88d38cf22ba2182d0981900a00a66506d80..fcb5d99f3918293f8c01df44610fe37ce92904ea 100644 (file)
@@ -1933,6 +1933,7 @@ struct libxl__domain_create_state {
 #define GC_INIT(ctx)  libxl__gc gc[1]; LIBXL_INIT_GC(gc[0],ctx)
 #define GC_FREE       libxl__free_all(gc)
 #define CTX           libxl__gc_owner(gc)
+#define NOGC          NULL
 
 /* Allocation macros all of which use the gc. */