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

Re: [Xen-devel] [PATCH 1/2] xen: Introduce an xmemdup() helper



>>> On 10.07.18 at 10:32, <roger.pau@xxxxxxxxxx> wrote:
> On Mon, Jul 09, 2018 at 11:29:47AM +0100, Andrew Cooper wrote:
>> --- 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_));

Wouldn't this second line again discard const then? If anything I
was wondering whether p_ is needed in the first place.

Jan



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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