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

Re: [libvirt] [PATCHv4 01/17] util: add VIR_(APPEND|INSERT|DELETE)_ELEMENT



On 12/10/2012 06:36 PM, Eric Blake wrote:
> On 12/10/2012 02:20 PM, Laine Stump wrote:
>> I noticed when writing the backend functions for virNetworkUpdate that
>> I was repeating the same sequence of memmove, VIR_REALLOC, nXXX-- (and
>> messed up the args to memmove at least once), and had seen the same
>> sequence in a lot of other places, so I decided to write a few
>> utility functions/macros - see the .h file for full documentation.
>>
>> The intent is to reduce the number of lines of code, but more
>> importantly to eliminate the need to check the element size and
>> element count arithmetic every time we need to do this (I *always*
>> make at least one mistake.)
>>
>> VIR_INSERT_ELEMENT: insert one element at an arbitrary index within an
>>   array of objects. The size of each object is determined
>>   automatically by the macro using sizeof(*array). If a pointer to a
>>   new element is provided, its contents are copied into the inserted
>>   space then the original contents are 0'ed out; if no newelem is
>>   provided the new space is set to all 0.
> This is slightly out of date, now that we reworked things to always add
> a new element.  (Our IRC conversation was that the underlying function
> should still support NULL instead of an array, but that we won't worry
> about passing NULL via the macros until we have a need for a
> VIR_INSERT_N_ELEMENTS macro later on).

I made all the changes that both you and Doug pointed out, and pushed
this patch. I'm also pushing 2/17, but saving the rest until "later"
(maybe after 1.0.1 is released?)

Thanks for the reviews!


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