Skip to content

Commit

Permalink
libxl: convert malloc() to libxl__zalloc(NULL, ...)
Browse files Browse the repository at this point in the history
And ditch the error handling in libxl_get_cpu_topology()

Signed-off-by: Dario Faggioli <[email protected]>
Acked-by: Ian Campbell <[email protected]>
[ ijc -- define and use NOGC instead of NULL to allow improvements to this
          infrastructure in the future ]
Committed-by: Ian Campbell <[email protected]>
  • Loading branch information
dfaggioli committed Jun 6, 2012
1 parent b4cf0e8 commit 6cf7902
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
7 changes: 1 addition & 6 deletions tools/libxl/libxl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) ? \
Expand Down
1 change: 1 addition & 0 deletions tools/libxl/libxl_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */

Expand Down

0 comments on commit 6cf7902

Please sign in to comment.