[GRASS-dev] Re: new version of lib/linkm (linked list memory manager)

Glynn Clements glynn at gclements.plus.com
Sun Oct 5 15:20:07 EDT 2008


Rosen Matev wrote:

> >> > I've written a new version of lib/linkm. It's interface is pretty much
> >> > the same. Names of functions, variables and the module itself are
> >> > subject to revision, as well as the documentation is (my English is
> >> > not that good). I've done some testing, the lib works correctly and
> >> > outperforms conventional linked list 4 to 12 times. Read the
> >> > documentation in linked_list.c for more info.
> >> > I'm looking forward to incorporating this into GRASS, since lists are
> >> > needed in Vect_get_point_in_poly() and the current library is buggy.
> >> > Here is what I've written.
> >>
> >> I really need some help to integrate this one into trunk. The current
> >> module prevents Vect_get_point_in_poly() from working correctly in
> >> some unusual cases.
> >
> > So are you going to modify your code to match the existing linkm
> > library, or modify the vector and bitmap libraries to use the new
> > interface?
> 
> I was hoping for more experienced grass developers to suggest the
> names of the functions and etc. Then I'll modify what's needed and
> give diffs to someone to apply them in trunk.

The functions used by the bitmap and vector libraries are:

link_cleanup
link_dispose
link_exit_on_error
link_init
link_new
link_set_chunk_size

In spite of the name, its only use purpose appears to be as an
allocator of fixed-sized blocks. In which case, even the proposed
replacement seems too complex.

We probably don't need (or want) to free individual chunks as they
become empty; they can be retained for future allocations. We just
need to free everything in link_dispose().

OTOH, I don't even know if we really need *any* of this. Certainly,
the code in lib/Vlib/poly.c could quite easily just use a realloc()ed
array, with link pointers being replaced by array indices.

The bitmap code probably could as well, although it would need a bit
more work. But then, AFAICT, nothing actually creates sparse bitmaps
(which are the sole reason that the bitmap library uses the link
library).

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list