[Devel] Re: [RFCv2][PATCH] flexible array implementation
Dave Hansen
dave at linux.vnet.ibm.com
Wed Jul 22 22:41:37 PDT 2009
On Wed, 2009-07-22 at 16:20 -0700, Benjamin Blum wrote:
>
> >> How about a resize() function that can be
> >> used to either grow or shrink the array?
> >
> > I think growing is out of the question. It has a fixed maximum size
> > already. As for shrinking, there's probably a use case for when
> > something is large, then shrinks back down. But, I think I'd want to
> > see a user for it, otherwise I'm just guessing at it too much.
>
> Check out the reallocate logic in pidlist_uniq from my patch (the
> series you linked).
To me, it seems like you should just replace the cgroup_pidlist->list
with a 'struct flex_array *'. It sounds like you're concerned that a
large cgroup_pidlist that was later shrunk would take up too much space.
That's a valid concern and it would be quite possible to make a
flex_array_clean() or truncate() or something similar. Such a function,
given an index, could clean out the array at all points past the given
index. Kinda the opposite of prealloc().
At the same time, you could get the same effect by allocating a new flex
array and doing copies like you are now with the normal arrays.
-- Dave
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
More information about the Devel
mailing list