[libvirt] [PATCH 1/1] Implement variable length structure allocator

2010-04-05 Thread David Allan
* This patch implements a memory allocator to obtain memory for structures whose last member is a variable length array. C99 refers to these variable length objects as structs containing flexible array members. --- src/util/memory.c | 40 src/util/

Re: [libvirt] [PATCH 1/1] Implement variable length structure allocator

2010-04-05 Thread Eric Blake
On 04/05/2010 11:21 AM, David Allan wrote: > +int virAllocVar(void *ptrptr, size_t struct_size, size_t element_size, > size_t count) Shouldn't that be void **ptrptr - that is, the caller passes in the address of a void* that we then modify? > +{ > +size_t alloc_size = 0; > + > +#if TEST_OOM

Re: [libvirt] [PATCH 1/1] Implement variable length structure allocator

2010-04-06 Thread Daniel P. Berrange
On Mon, Apr 05, 2010 at 11:51:48AM -0600, Eric Blake wrote: > On 04/05/2010 11:21 AM, David Allan wrote: > > +int virAllocVar(void *ptrptr, size_t struct_size, size_t element_size, > > size_t count) > > Shouldn't that be void **ptrptr - that is, the caller passes in the > address of a void* that

Re: [libvirt] [PATCH 1/1] Implement variable length structure allocator

2010-04-06 Thread Dave Allan
On 04/05/2010 01:51 PM, Eric Blake wrote: On 04/05/2010 11:21 AM, David Allan wrote: +int virAllocVar(void *ptrptr, size_t struct_size, size_t element_size, size_t count) Shouldn't that be void **ptrptr - that is, the caller passes in the address of a void* that we then modify? +{ +size

Re: [libvirt] [PATCH 1/1] Implement variable length structure allocator

2010-04-07 Thread Eric Blake
On 04/06/2010 06:59 AM, Dave Allan wrote: >> Then again, fixing the type for your new method would imply fixing the >> typing of virAlloc and friends as well. Daniel's arguments are convincing; it's okay to keep the ugly cast in the implementation if it makes the header easier to use without havin

Re: [libvirt] [PATCH 1/1] Implement variable length structure allocator

2010-04-07 Thread Dave Allan
On 04/07/2010 10:17 AM, Eric Blake wrote: On 04/06/2010 06:59 AM, Dave Allan wrote: Then again, fixing the type for your new method would imply fixing the typing of virAlloc and friends as well. Daniel's arguments are convincing; it's okay to keep the ugly cast in the implementation if it make

Re: [libvirt] [PATCH 1/1] Implement variable length structure allocator

2010-04-14 Thread Dave Allan
On Wed, Apr 07, 2010 at 12:49:46PM -0400, Dave Allan wrote: > On 04/07/2010 10:17 AM, Eric Blake wrote: > >On 04/06/2010 06:59 AM, Dave Allan wrote: > >>>Then again, fixing the type for your new method would imply fixing the > >>>typing of virAlloc and friends as well. > > > >Daniel's arguments are

Re: [libvirt] [PATCH 1/1] Implement variable length structure allocator

2010-04-14 Thread Daniel P. Berrange
On Wed, Apr 14, 2010 at 01:31:15PM -0400, Dave Allan wrote: > On Wed, Apr 07, 2010 at 12:49:46PM -0400, Dave Allan wrote: > > On 04/07/2010 10:17 AM, Eric Blake wrote: > > >On 04/06/2010 06:59 AM, Dave Allan wrote: > > >>>Then again, fixing the type for your new method would imply fixing the > > >>

Re: [libvirt] [PATCH 1/1] Implement variable length structure allocator

2010-04-14 Thread Dave Allan
On Wed, Apr 14, 2010 at 06:37:35PM +0100, Daniel P. Berrange wrote: > On Wed, Apr 14, 2010 at 01:31:15PM -0400, Dave Allan wrote: > > On Wed, Apr 07, 2010 at 12:49:46PM -0400, Dave Allan wrote: > > > On 04/07/2010 10:17 AM, Eric Blake wrote: > > > >On 04/06/2010 06:59 AM, Dave Allan wrote: > > > >>