[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH V3] xl: create VFB for PV guest when VNC is specified



On Mon, Dec 16, 2013 at 05:46:04PM +0000, Ian Campbell wrote:
[...]
> > Changes in V2:
> > * use macros to reduce code duplication
> > * vfb=[] take precedence over top level VNC options
> > ---
> >  tools/libxl/xl_cmdimpl.c |   89 
> > ++++++++++++++++++++++++++++++++++++----------
> >  1 file changed, 70 insertions(+), 19 deletions(-)
> > 
> > diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> > index bd26bcc..6a22e17 100644
> > --- a/tools/libxl/xl_cmdimpl.c
> > +++ b/tools/libxl/xl_cmdimpl.c
> > @@ -315,6 +315,13 @@ static void *xrealloc(void *ptr, size_t sz) {
> >      return r;
> >  }
> >  
> > +#define ARRAY_EXTEND(array,count)                                       \
> > +    do {                                                                \
> > +        (array) = xrealloc((array),                                     \
> > +                           sizeof(typeof(*(array))) * ((count) + 1));   \
> 
> sizeof(typeof(*array)) == sizeof(*array), doesn't it?
> 
> > +        (count) = (count) + 1;                                          \
> 
> (count++)
> 
> I suppose in a macro like this it is tricky to arrange to only evaluate
> the arguments once, since you need to read and write, but I think you
> can arrange to evaluate array exactly once instead of 3 times and count
> just once.
> 

I came up with this. Is it what you asked for?

#define ARRAY_EXTEND(type_ptr,ptr,type_count,count,ret)                 \
    do {                                                                \
        type_ptr **__ptr = &(ptr);                                      \
        type_count *__count = &(count);                                 \
        *__ptr = xrealloc(*__ptr,                                       \
                          sizeof(**__ptr) * (*__count + 1));            \
        (ret) = *__ptr + *__count;                                      \
        (*__count)++;                                                   \
    } while (0)

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.