On Monday 08 October 2007 02:33, Nicholas Nethercote wrote:

> I altered the OSet interface recently on the trunk to make it much easier
> to use it for word-to-word maps.  Could you take a look at it and see if it
> does the same things as your TC_wordfm.c?  It would be good to avoid such
> code duplication.

Removing the duplication would be good.  I've wondered about that 
from time to time, and saw your commit the other day.  Here's a summary
of the differences, from looking at the interfaces:

I can see that OSetWord makes it easy to do sets of words, but I'm
not sure how to use it for word-to-word maps.  I would have expected
OSetWord_Insert to take two words, a (key,val) pair (a la addToFM),
OSetWord_Contains to return a Bool and, if that is True, a Word (a la
lookupFM).

The behaviour of OSetWord_Insert vs addToFM are different when an 
existing key is added: the former asserts, the latter replaces the
existing binding.  That's not a big deal; probably there is a case
for having both behaviours.

I think the only other frills in WordFM are to do with storage
management.

* delFromFM returns the (key,value) pair that was deleted, so that
  the caller can free the key and/or value if either of those point
  to dynamically allocated memory.  Note that the key returned may
  not necessarily be the same (Word) as the key you asked to delete;
  they only need to be equal modulo the comparison fn.  That's why
  both the val and the key are made available.

* for similar reasons, lookupFM (a la OSetWord_Contains) produces
  both the existing key and value, if asked to

* deleteFM (free up the entire FM) allows calling arbitrary
  finaliser fns on the keys and values.

* I don't think dopyFM is used.  It could be removed.  That would
  simplify things.

Some time back I spent a couple of hours trying to see if I could 
implement WordFM on top of OSet (general), but got into difficulties
with some of the finer points of storage management.  I don't remember
any more than that.  Perhaps worth revisiting.

J

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Valgrind-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-developers

Reply via email to