[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] libxl: document the memory ownership of some functions


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Wed, 04 Jul 2012 04:11:09 +0000
  • Delivery-date: Wed, 04 Jul 2012 04:11:18 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Dario Faggioli <dario.faggioli@xxxxxxxxxx>
# Date 1340894642 -3600
# Node ID f347d62595011cd6b8baece7bc2a0e4d1d875b14
# Parent  efd12cc7dd99fa855d98025d97d5cbcbf1445e73
libxl: document the memory ownership of some functions

Specifying they allocate dynamic memory that needs to be explicitly freed.

Signed-off-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx>
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---


diff -r efd12cc7dd99 -r f347d6259501 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Thu Jun 28 16:04:12 2012 +0200
+++ b/tools/libxl/libxl.c       Thu Jun 28 15:44:02 2012 +0100
@@ -508,7 +508,7 @@ static void xcinfo2xlinfo(const xc_domai
     xlinfo->cpupool = xcinfo->cpupool;
 }
 
-libxl_dominfo * libxl_list_domain(libxl_ctx *ctx, int *nb_domain)
+libxl_dominfo * libxl_list_domain(libxl_ctx *ctx, int *nb_domain_out)
 {
     libxl_dominfo *ptr;
     int i, ret;
@@ -531,7 +531,7 @@ libxl_dominfo * libxl_list_domain(libxl_
     for (i = 0; i < ret; i++) {
         xcinfo2xlinfo(&info[i], &ptr[i]);
     }
-    *nb_domain = ret;
+    *nb_domain_out = ret;
     return ptr;
 }
 
@@ -589,7 +589,7 @@ int libxl_cpupool_info(libxl_ctx *ctx,
     return rc;
 }
 
-libxl_cpupoolinfo * libxl_list_cpupool(libxl_ctx *ctx, int *nb_pool)
+libxl_cpupoolinfo * libxl_list_cpupool(libxl_ctx *ctx, int *nb_pool_out)
 {
     GC_INIT(ctx);
     libxl_cpupoolinfo info, *ptr, *tmp;
@@ -613,14 +613,15 @@ libxl_cpupoolinfo * libxl_list_cpupool(l
         poolid = info.poolid + 1;
     }
 
-    *nb_pool = i;
+    *nb_pool_out = i;
 out:
     GC_FREE;
     return ptr;
 }
 
-/* this API call only list VM running on this host. a VM can be an aggregate 
of multiple domains. */
-libxl_vminfo * libxl_list_vm(libxl_ctx *ctx, int *nb_vm)
+/* this API call only list VM running on this host. A VM can
+ * be an aggregate of multiple domains. */
+libxl_vminfo * libxl_list_vm(libxl_ctx *ctx, int *nb_vm_out)
 {
     libxl_vminfo *ptr;
     int index, i, ret;
@@ -644,7 +645,7 @@ libxl_vminfo * libxl_list_vm(libxl_ctx *
 
         index++;
     }
-    *nb_vm = index;
+    *nb_vm_out = index;
     return ptr;
 }
 
@@ -3161,7 +3162,7 @@ int libxl_get_physinfo(libxl_ctx *ctx, l
     return 0;
 }
 
-libxl_cputopology *libxl_get_cpu_topology(libxl_ctx *ctx, int *nr)
+libxl_cputopology *libxl_get_cpu_topology(libxl_ctx *ctx, int *nb_cpu_out)
 {
     xc_topologyinfo_t tinfo;
     DECLARE_HYPERCALL_BUFFER(xc_cpu_to_core_t, coremap);
@@ -3219,7 +3220,7 @@ fail:
     xc_hypercall_buffer_free(ctx->xch, nodemap);
 
     if (ret)
-        *nr = max_cpus;
+        *nb_cpu_out = max_cpus;
     return ret;
 }
 
@@ -3270,7 +3271,7 @@ const libxl_version_info* libxl_get_vers
 }
 
 libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,
-                                       int *nb_vcpu, int *nrcpus)
+                                       int *nb_vcpu, int *nr_vcpus_out)
 {
     libxl_vcpuinfo *ptr, *ret;
     xc_domaininfo_t domaininfo;
@@ -3280,7 +3281,7 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ct
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting infolist");
         return NULL;
     }
-    *nrcpus = libxl_get_max_cpus(ctx);
+    *nr_vcpus_out = libxl_get_max_cpus(ctx);
     ret = ptr = calloc(domaininfo.max_vcpu_id + 1, sizeof (libxl_vcpuinfo));
     if (!ptr) {
         return NULL;
diff -r efd12cc7dd99 -r f347d6259501 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Thu Jun 28 16:04:12 2012 +0200
+++ b/tools/libxl/libxl.h       Thu Jun 28 15:44:02 2012 +0100
@@ -585,12 +585,28 @@ int libxl_primary_console_get_tty(libxl_
 /* May be called with info_r == NULL to check for domain's existance */
 int libxl_domain_info(libxl_ctx*, libxl_dominfo *info_r,
                       uint32_t domid);
-libxl_dominfo * libxl_list_domain(libxl_ctx*, int *nb_domain);
-void libxl_dominfo_list_free(libxl_dominfo *list, int nr);
-libxl_cpupoolinfo * libxl_list_cpupool(libxl_ctx*, int *nb_pool);
-void libxl_cpupoolinfo_list_free(libxl_cpupoolinfo *list, int nr);
-libxl_vminfo * libxl_list_vm(libxl_ctx *ctx, int *nb_vm);
-void libxl_vminfo_list_free(libxl_vminfo *list, int nr);
+
+/* These functions each return (on success) an array of elements,
+ * and the length via the int* out parameter.  These arrays and
+ * their contents come from malloc, and must be freed with the
+ * corresponding libxl_THING_list_free function.
+ */
+libxl_dominfo * libxl_list_domain(libxl_ctx*, int *nb_domain_out);
+void libxl_dominfo_list_free(libxl_dominfo *list, int nb_domain);
+
+libxl_cpupoolinfo * libxl_list_cpupool(libxl_ctx*, int *nb_pool_out);
+void libxl_cpupoolinfo_list_free(libxl_cpupoolinfo *list, int nb_pool);
+
+libxl_vminfo * libxl_list_vm(libxl_ctx *ctx, int *nb_vm_out);
+void libxl_vminfo_list_free(libxl_vminfo *list, int nb_vm);
+
+#define LIBXL_CPUTOPOLOGY_INVALID_ENTRY (~(uint32_t)0)
+libxl_cputopology *libxl_get_cpu_topology(libxl_ctx *ctx, int *nb_cpu_out);
+void libxl_cputopology_list_free(libxl_cputopology *, int nb_cpu);
+
+libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,
+                                int *nb_vcpu, int *nr_vcpus_out);
+void libxl_vcpuinfo_list_free(libxl_vcpuinfo *, int nr_vcpus);
 
 /*
  * Devices
@@ -766,12 +782,6 @@ int libxl_userdata_retrieve(libxl_ctx *c
    */
 
 int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo);
-#define LIBXL_CPUTOPOLOGY_INVALID_ENTRY (~(uint32_t)0)
-libxl_cputopology *libxl_get_cpu_topology(libxl_ctx *ctx, int *nr);
-void libxl_cputopology_list_free(libxl_cputopology *, int nr);
-libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,
-                                       int *nb_vcpu, int *nrcpus);
-void libxl_vcpuinfo_list_free(libxl_vcpuinfo *, int nr);
 int libxl_set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid,
                            libxl_cpumap *cpumap);
 int libxl_set_vcpuaffinity_all(libxl_ctx *ctx, uint32_t domid,

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.