On Fri, 03.05.13 09:30, Kok, Auke-jan H (auke-jan.h....@intel.com) wrote:

> >> The linked list approach drives down this memory requirement and makes
> >> navigating all the data much more straightforward. I also much prefer
> >> head pointers instead of having index numbers around.
> >
> > Still sounds like greedy_realloc() is what you want here. Storing sample
> > data in a dynamically increasing array sounds much more natural than a
> > linked list.
> 
> I admit I hadn't heard of greedy_realloc() unti Zbigniew mentioned it,
> and I still fail to see why it would be so much better other than "you
> can access members by index". You're still doing an allocation each
> time you extend the array (unless you're doing tricks and
> preallocate).

Yes, that's what it does, it reallocates with exponentially increasing
sizes.

The benefit is random access and a you need two pointers less per entry,
which is quite something on 64bit...

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to