xcp-1.6-updates/xen-4.1.hg

changeset 23256:b7efb9e1a041

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>
xen-unstable changeset: 24709:8ba7ae0b070b
xen-unstable date: Tue Feb 07 18:46:50 2012 +0000
author Santosh Jodh <santosh.jodh@citrix.com>
date Wed Mar 07 09:39:10 2012 +0000 (2012-03-07)
parents 1f95b55ef427
children bcf1250a14e8
files tools/libxc/xc_linux_osdep.c
line diff
     1.1 --- a/tools/libxc/xc_linux_osdep.c	Wed Mar 07 09:34:26 2012 +0000
     1.2 +++ b/tools/libxc/xc_linux_osdep.c	Wed Mar 07 09:39:10 2012 +0000
     1.3 @@ -218,7 +218,7 @@ static void *linux_privcmd_map_foreign_b
     1.4           * IOCTL_PRIVCMD_MMAPBATCH_V2 is not supported - fall back to
     1.5           * IOCTL_PRIVCMD_MMAPBATCH.
     1.6           */
     1.7 -        xen_pfn_t *pfn = malloc(num * sizeof(*pfn));
     1.8 +        xen_pfn_t *pfn = alloca(num * sizeof(*pfn));
     1.9  
    1.10          if ( pfn )
    1.11          {
    1.12 @@ -264,8 +264,6 @@ static void *linux_privcmd_map_foreign_b
    1.13                  break;
    1.14              }
    1.15  
    1.16 -            free(pfn);
    1.17 -
    1.18              if ( rc == -ENOENT && i == num )
    1.19                  rc = 0;
    1.20              else if ( rc )
    1.21 @@ -532,7 +530,7 @@ static void *do_gnttab_map_grant_refs(xc
    1.22      void *addr = NULL;
    1.23      int i;
    1.24  
    1.25 -    map = malloc(sizeof(*map) +
    1.26 +    map = alloca(sizeof(*map) +
    1.27                   (count - 1) * sizeof(struct ioctl_gntdev_map_grant_ref));
    1.28      if ( map == NULL )
    1.29          return NULL;
    1.30 @@ -567,7 +565,6 @@ static void *do_gnttab_map_grant_refs(xc
    1.31      }
    1.32  
    1.33   out:
    1.34 -    free(map);
    1.35  
    1.36      return addr;
    1.37  }