pe, 2006-05-12 kello 20:30 +0200, Peter T. Breuer kirjoitti:
> man hash_iter
> 
>      hash_iter  goes  through  every element in the hash table and calls
>      the doit function.  If doit returns  -1  or  0,  hash_iter  will
>      stop  the traversal and return the same value.
> 
> Fine. And what exactly are the (two) arguments that the parameter
> function doit takes supposed to be?  Clear as mud!

Indeed.

Deducing from the source code, it looks to me that the parameters are
the data item (the one installed into the hash table with hash_install),
and the 'param' argument given to hash_iter itself.

> I think that doit is meant to return 1 always, and 0 or -1 is an
> "emergency breakout" signal when returned. What doit's arguments are
> remain opaque to me. I'm afraid I can't guess even looking at examples
> of my own code which uses this library function!  ... Lars is probably
> in the same position. This nail needs to be hammered down.

If the doit function returns 0, processing stops and hash_iter returns
0. If the doit function returns -1, processing stops and hash_iter
returns -1. Any other return values don't stop processing. If all items
in the hash table are processed (doit returns neither 0 nor -1 for any
of them), hash_iter returns 1.

I'll figure out a way to express this more clearly in the manpage for a
future upload.

-- 
Do, or do not. There is no angst.



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to