portability fixes
[rrq/rrqmisc.git] / typing / integeritem.c
1 #include <integeritem.h>
2
3 /**
4  * This callback function returns the hashcode of a key. The hashcode
5  * is used for indexing into the backing Vector for finding the an
6  * item via its key. The same key must map consistently to the same
7  * hashcode while the hashtable contains an item with that key.
8  * Different keys map map to the same hashcode, in which case the
9  * Vector placement is made at the first empty or hole slot following
10  * the hashcode index.
11  */
12 static unsigned long integeritem_hashcode(void *this,void *key) {
13     (void)this;
14     return (unsigned long) key;
15 }
16
17 /**
18  * This callback function determines whether an item has a
19  * given key or not.
20  */
21 static int integeritem_haskey(void *this,void *item,void *key) {
22     (void)this;
23     return item == key;
24 }
25
26 /**
27  * This callback function returns the key of an item by considering
28  * the arity and schema.
29  */
30 static void *integeritem_itemkey(void *this,void *item) {
31     (void)this;
32     return item;
33 }
34
35 /**
36  * This callback function handles a key obtained from the itemkey
37  * callback function to reclaim temporary allocation.
38  */
39 static void integeritem_releasekey(void *this,void *key) {
40     (void)this; (void)key;
41 }
42
43 /**
44  * This callback function writes a representation of an item into
45  * a character buffer.
46  */
47 static int integeritem_tostring(void *this,void *item,char *buffer,int limit) {
48     (void)this;
49     return snprintf( buffer, limit, "%lld", (long long) item );
50 }
51
52 ItemKeyFun integeritem = {
53     .hashcode = integeritem_hashcode,
54     .haskey = integeritem_haskey,
55     .itemkey = integeritem_itemkey,
56     .releasekey = integeritem_releasekey,
57     .tostring = integeritem_tostring
58 };