On 12/07/2012 01:53 PM, Eric Blake wrote:
On 12/07/2012 11:16 AM, Laine Stump wrote:
> DO NOT BE SCARED OFF BY THE PATCH COUNT!! Most of these are very
> short, and they all follow the same pattern; beyond that, 01/17 and
> 02/17 are the only ones that are really time-sensitive.
>
> The first patch in this series adds new macros to insert/append/delete
> elements from the arrays of variously-sized structs that are commonly
> used in libvirt. The intent is to eliminate the arithmetic mistakes
> associated with calling memmove() directly, and shorten application
> code. A full description of the added macros and their functions is
> included in 01/17.
>
> Patches 02..17 convert various bits of hand-coded array manipulation
> in libvirt to use the new macros. They can be taken now, later, or
> never (although I'd like to have at least 02/17 taken now, since other
> similar functions will be added in an upcoming patch series, and I
> want them to all use the same logic). Mostly I went through all of
> those conversions to see just how useful/usable the new macros were
> (and they led to a couple of rewrites).
>
> I will be posting another series momentarily that has a dependency on
> 01/17.
Dunno why you don't have a diffstat, to make it a bit more impressive
(the --cover-letter option to get send-email or git format will create a
diffstat into your 0/17 mail):
Ah, I always use --compose, and sometimes wondered why other people had
a diffstat and I didn't :-)
That is, in spite of 200+ lines added to memory.[ch], you still
managed
to let the series have a net reduction of nearly 200 lines to the
overall code base by shaving redundant code elsewhere, all while making
the usage pattern safer :)
There's still a couple of disappointments:
1) I have to typecast a NULL newelem
2) I had to add the silly "_COPY" versions of the macros because
sometimes the element being inserted to an array is just a pointer, and
the caller wants to continue to use that same reference to it after return.