[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 1/2] xen: Introduce an xmemdup() helper
On Mon, Jul 09, 2018 at 11:29:47AM +0100, Andrew Cooper wrote: > ... and use it in place of the opencoded instances. > > For consistency, restructure init_domain_cpuid_policy() to be like > init_{domain,vcpu}_msr_policy() by operating on the local pointer where > possible. > > No change in behaviour. > > Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> > diff --git a/xen/include/xen/xmalloc.h b/xen/include/xen/xmalloc.h > index cc2673d..34c6588 100644 > --- a/xen/include/xen/xmalloc.h > +++ b/xen/include/xen/xmalloc.h > @@ -13,6 +13,16 @@ > #define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type), __alignof__(_type))) > #define xzalloc(_type) ((_type *)_xzalloc(sizeof(_type), __alignof__(_type))) > > +/* Allocate space for a typed object and copy an existing instance. */ > +#define xmemdup(ptr) \ > +({ \ > + typeof(*(ptr)) *p_ = (ptr), *n_ = xmalloc(typeof(*p_)); \ Could you do? const typeof(*(ptr)) *p_ = (ptr); typeof(*(ptr)) *n_ = xmalloc(typeof(*p_)); Roger. _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |