2 #include <HashVector.h>
6 * This callback function returns the hashcode of a Binding key, which
9 static unsigned long Binding_hashcode(void *this,void *key) {
10 return HashVector_hashcode(
11 (unsigned char *) key, strlen( (char*) key ) );
15 * This callback function determines whether a Binding item has a
18 static int Binding_haskey(void *this,void *item,void *key) {
19 Binding *b = (Binding*) item;
20 char *name = (char *) key;
21 return strcmp( name, (char*) b->name ) == 0;
25 * This callback function returns the key of a Binding itme, which is
28 static void *Binding_itemkey(void *this,void *item) {
29 return ((Binding*) item)->name;
34 * This callback function handles the "release" of a Binding key,
35 * which is to do nothing, since the name string memory is not managed
38 static void Binding_releasekey(void *this,void *key) {
42 * This callback function writes a representation of a Binding item
43 * into a character buffer.
45 static int Binding_tostring(void *this,void *item,char *buffer,int limit) {
46 Binding *b = (Binding*) item;
47 return snprintf( buffer, limit, "{%s,%p}", b->name, b->value );
51 * This is the "item type" for Binding items.
53 ItemKeyFun Bindingitem = {
54 .hashcode = Binding_hashcode,
55 .haskey = Binding_haskey,
56 .itemkey = Binding_itemkey,
57 .releasekey = Binding_releasekey,
58 .tostring = Binding_tostring