mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
libxc: Replace malloc with alloca in hot path
Replace malloc with alloc in hot paths for improved performance. Signed-off-by: Santosh Jodh <santosh.jodh@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
This commit is contained in:
1 parent
6817a0ff5c
commit
3e6f9ecb2e
1 file changed
+2
-5
@@ -243,7 +243,7 @@ static void *linux_privcmd_map_foreign_bulk(xc_interface *xch, xc_osdep_handle h
|
||||
* IOCTL_PRIVCMD_MMAPBATCH_V2 is not supported - fall back to
|
||||
* IOCTL_PRIVCMD_MMAPBATCH.
|
||||
*/
|
||||
xen_pfn_t *pfn = malloc(num * sizeof(*pfn));
|
||||
xen_pfn_t *pfn = alloca(num * sizeof(*pfn));
|
||||
|
||||
if ( pfn )
|
||||
{
|
||||
@@ -289,8 +289,6 @@ static void *linux_privcmd_map_foreign_bulk(xc_interface *xch, xc_osdep_handle h
|
||||
break;
|
||||
}
|
||||
|
||||
free(pfn);
|
||||
|
||||
if ( rc == -ENOENT && i == num )
|
||||
rc = 0;
|
||||
else if ( rc )
|
||||
@@ -525,7 +523,7 @@ static void *linux_gnttab_grant_map(xc_gnttab *xch, xc_osdep_handle h,
|
||||
if (flags & XC_GRANT_MAP_SINGLE_DOMAIN)
|
||||
domids_stride = 0;
|
||||
|
||||
map = malloc(sizeof(*map) +
|
||||
map = alloca(sizeof(*map) +
|
||||
(count - 1) * sizeof(struct ioctl_gntdev_map_grant_ref));
|
||||
if ( map == NULL )
|
||||
return NULL;
|
||||
@@ -599,7 +597,6 @@ static void *linux_gnttab_grant_map(xc_gnttab *xch, xc_osdep_handle h,
|
||||
}
|
||||
|
||||
out:
|
||||
free(map);
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||