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:
Santosh Jodh committed 2012-02-07 18:46:50 +00:00
1 parent 6817a0ff5c
commit 3e6f9ecb2e
1 file changed
+2 -5
+2 -5
View File
@@ -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;
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.