@@ -236,6 +236,8 @@ struct xc_sr_save_arrays {
};
struct xc_sr_restore_arrays {
+ /* handle_page_data */
+ xen_pfn_t pfns[MAX_BATCH_SIZE];
};
struct xc_sr_context
@@ -315,7 +315,7 @@ static int handle_page_data(struct xc_sr_context *ctx, struct xc_sr_record *rec)
unsigned int i, pages_of_data = 0;
int rc = -1;
- xen_pfn_t *pfns = NULL, pfn;
+ xen_pfn_t *pfns = ctx->restore.m->pfns, pfn;
uint32_t *types = NULL, type;
/*
@@ -363,9 +363,8 @@ static int handle_page_data(struct xc_sr_context *ctx, struct xc_sr_record *rec)
goto err;
}
- pfns = malloc(pages->count * sizeof(*pfns));
types = malloc(pages->count * sizeof(*types));
- if ( !pfns || !types )
+ if ( !types )
{
ERROR("Unable to allocate enough memory for %u pfns",
pages->count);
@@ -412,7 +411,6 @@ static int handle_page_data(struct xc_sr_context *ctx, struct xc_sr_record *rec)
&pages->pfn[pages->count]);
err:
free(types);
- free(pfns);
return rc;
}
Remove allocation from hotpath, move pfns array into preallocated space. Signed-off-by: Olaf Hering <olaf@aepfle.de> --- tools/libs/saverestore/common.h | 2 ++ tools/libs/saverestore/restore.c | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-)